1、ruby 系统自带,安装 Rails(省略),Apache 系统自带,Rails App(省略) 2、安装 passenger
gem install passenger
passenger-install-apache2-module
记录输出如下:
LoadModule passenger_module /Users/Peter/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.55/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /Users/Peter/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.55
PassengerDefaultRuby /Users/Peter/.rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>
3, Rails App bundle gems
bundle --deployment
4、修改 Apache 文件
sudo vi /etc/apache2/httpd.conf
此处将VirtualHost的环境设置为development
LoadModule passenger_module /Users/Peter/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.55/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /Users/Peter/.rvm/gems/ruby-2.1.1/gems/passenger-4.0.55
PassengerDefaultRuby /Users/Peter/.rvm/gems/ruby-2.1.1/wrappers/ruby
</IfModule>
<VirtualHost *:80>
DocumentRoot "/Users/Peter/workspace/apps/public"
ServerName Peter
RailsEnv development
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Require all granted
#去掉随后注释及注释掉Require all granted后,仅允许本地访问
#Deny from all
#Allow from 127.0.0.1
#Allow from ::1
#Satisfy Any
</Directory>
</VirtualHost>
5、Apache 相关命令
sudo apachectl -v
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
6、系统自动加载 Apache
随系统自动加载
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
停止系统自动加载
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
7、系统自动加载 Mysql
因为系统自带的Mysql版本,不能完成系统启动时加载,因此需要下载mysql 5.6.21以上的版本。
下载地址为:http://dev.mysql.com/downloads/mysql/
为了能够自动引导,分为两步来完成工作。
A、首先,创建一个新文件 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
增加如下内容并保存:
<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>
</dict>
</plist>
B、修改权限,并加入自动引导目录中 launchctl:
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
停止自动引导命令如下:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist