日期:2014-05-16  浏览次数:20799 次

Ubuntu下 apache2+Phusion Passenger

Ubuntu下 apache2+Phusion Passenger (此内容转载+个人修改 原链接:http://binku.iteye.com/blog/483687 )

?

Phusion Passenger ?Users guide :http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root

?

?

Apache configuration files on Ubuntu : http://articles.slicehost.com/2010/5/19/apache-configuration-files-on-ubuntu

?

---------------------------------------------------------------

?

(1)安装apache: sudo apt-get install apache2
(2)安装passenger

????$ gem install passenger
????$ passenger-install-apache2-module ? #注意过程中提示可能会出现缺失gem
????安装到最後时,会出现如下的3条语句:

?

? ?默认情况下:加载的是本地系统中的gem,但如果你使用rvm进行buby的版本控制的话需要把gem指定成rvm中的gem路径,配置文件中C-V的内容注意

?

? ?LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so

? ?PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.9

? ?PassengerRuby /usr/bin/ruby1.8


?


?? LoadModule passenger_module /home/administrator/.rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/ext/apache2/mod_passenger.so

? PassengerRoot /home/administrator/.rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9

? PassengerRuby /home/administrator/.rvm/wrappers/ruby-1.8.7-p352/ruby

?

????把三条语句复制到/etc/apache2/apache2.conf的最后

?


(3)在/etc/apache2/sites-available下面创建available的应用配置
????$ sudo touch /etc/apache2/sites-available/rails-app #project.com
????打开rails-app,加入以下语句:
????????<VirtualHost *:80>?
???????????# RailsEnv development 加上这句的话,以development的模式部署
????????????ServerName binku.com
????????????DocumentRoot /home/binku/programme/rails-app/public
????????</VirtualHost>

?

?

<VirtualHost *:80>

? ServerName elischina.local ?#映射的虚拟地址

? DocumentRoot /home/administrator/11111111111/elischina/public #目录一定要指向public

? <Directory /home/administrator/11111111111/elischina/public>

? ? ?Allow from all

? ? ?Options -MultiViews

? ? ?RailsEnv ?development ?#默认的是加载production的环境 ,如果用production环境,后面启动服务器的时候会出现css,js...加载的错误,文档中有说明:在config/environments/production.rb中?config.assets.compile = true (默认为false)改为true ?( http://stackoverflow.com/questions/7275636/rails-3-1-0-actionviewtemplateerrror-application-css-isnt-precompiled )

? </Directory>

</VirtualHost>


?


(4)创建软链接,把available的应用程序配置链接到/etc/apache2/sites-enabled下面,apache将读取该文件夹下的配置.
???$ sudo ln -s /etc/apache2/sites-available/rails-app /etc/apache2/