1.安装Apache
sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev
2.安装passenger
gem install passenger
3.安装桥接器模块
passenger-install-apache2-module
或者,如果你用的是Nginx,则:
passenger-install-nginx-module
4.在运行 passenger-install-apache2-module 命令的时候,会出现类似一下的代码,让你放到apaceh2.conf文件的最后
LoadModule passenger_module /home/justqyx/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.13/ext/apache2/mode_passenger.so PassengerRoot /home/justqyx/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.13 PassengerRuby /home/justqyx/.rvm/wrappers/ruby-1.9.2-p290/ruby
顺便检查有没有以下的这两行配置,没有的话顺便加上
Include sites-available/ ServerName 127.0.0.1
注意:此步可能会出现错误,要按照终端的提示来安装额外的东西
5.配置文件apache2
在etc/apach2/sites-available目录下增加cl文件,然后把
listen 4100
<VirtualHost *:4100>
ServerName localhost
DocumentRoot /home/aaron/code/cl/public
RailsEnv production
<Directory /home/aaron/code/cl/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
强制重新加载服务器配置文件
sudo /etc/init.d/apache2 force-reload
或者sudo /etc/init.d/apache2 reload
重启服务器
sudo /etc/init.d/apache2 restart
注意:终止服务器: sudo /etc/init.d/apache2/ stop
启动服务器: sudo /etc/init.d/apache2/start