1、安装apache
sudo apt-get install apache2
打开浏览器,请求http://localhost,出现如下界面,证明安装成功
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
2、安装passenger和apache模块
sudo gem install passenger
sudo passenger-install-apache2-module
运行这个命令如果出现如下错误
sudo: passenger-install-apache2-module: command not found
说明gem的bin目录没有加到PATH下,
解决方法:
一是把gem的bin目录路径加到PATH下,参考
http://jadeluo.iteye.com/blog/940113
二是用全路径执行passenger-install-apache2-module,执行如下命令:
sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module
如果不知道gem的bin路径,执行命令:
gem environment
3、修改apache配置文件/etc/apache2/httpd.conf
在httpd.conf中增加如下内容:
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.5/ext/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.5
PassengerRuby /usr/bin/ruby1.8
<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!
<Directory /somewhere/public>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
4、重启apache,执行/etc/init.d/apache2 restart,出现如下错误:
Syntax error on line 7 of /etc/apache2/httpd.conf:DocumentRoot takes one argument,
Root directory of the document treeAction 'configtest' failed.The Apache error log may have more information.
...fail!
解决如上错误,需要删除http.conf文件中 DocumentRoot /somewhere/public 后面的# <-- be sure to point to 'public'!