Linux Deploy Rails3 with Ruby1.9.2(4)Configure the rails in Apache2
LinuxDeployRails3withRuby1.9.2(4)ConfiguretherailsinApache2
Changetheconfigurationofapache2
>vihttpd.conf
LoadModulepassenger_module/home/luohua/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
PassengerRoot/home/luohua/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9/gems/passenger-3.0.8
PassengerRuby/home/luohua/.rvm/rubies/ruby-1.9.2-p290
trytorestarttheapacheserver
>bin/apachelrestart
errormessages:
httpd:Syntaxerroronline423of/opt/tools/httpd/conf/httpd.conf:APImodulestructure'passenger_module'infile/home/luohua/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9/gems/passenger-3.0.8/ext/apache2/mod_passenger.soisgarbled-expectedsignature41503232butsaw41503230-perhapsthisisnotanApachemoduleDSO,orwascompiledforadifferentApacheversion?
solutions:
ThatisbecauseIhave2versionofapache2onmyserver.Iwillusetheonewhocompiledpassenger.
Thecompilepassengerinformation:
*Apache2...foundat/usr/bin/httpd
*Apache2developmentheaders...foundat/usr/sbin/apxs
*ApachePortableRuntime(APR)developmentheaders...foundat/usr/bin/apr-config
*ApachePortableRuntimeUtility(APU)developmentheaders...foundat/usr/bin/apu-config
>sudomv/usr/sbin/httpd/usr/sbin/httpd.bak
>sudoln-s/opt/tools/httpd/bin/httpd/usr/bin/httpd
>sudomv/usr/sbin/apxs/usr/sbin/apxs.bak
>sudoln-s/opt/tools/httpd/bin/apxs/usr/sbin/apxs
findtheversionofapache
>bin/apachectl-V|grepSERVER_CONFIG_FILE
locatedtheAPXS2
>exportAPXS2=/opt/tools/httpd/bin/apxs
trytorestarttheapacheagain
>bin/apachelrestart
errormessage:
[WedAug3114:47:232011][notice]SIGHUPreceived.Attemptingtorestart
***PassengerERROR(ext/common/ApplicationPool/../SpawnManager.h:220):
Couldnotstartthespawnserver:/home/luohua/.rvm/rubies/ruby-1.9.2-p290:Permissiondenied(13)
[pid=14425thr=3086257024file=ext/apache2/HelperAgent.cpp:354time=2011-08-3114:47:23.906]:Couldnotstartthespawnserver:write()failed:Brokenpipe(32)
in'Passenger::SpawnManager::SpawnManager(conststd::string&,constboost::shared_ptr<Passenger::ServerInstanceDir::Generation>&,constPassenger::AccountsDatabasePtr&,conststd::string&,constPassenger::AnalyticsLoggerPtr&,int,conststd::string&)'(SpawnManager.h:540)
in'Passenger::ApplicationPool::Pool::Pool(conststd::string&,constboost::shared_ptr<Passenger::ServerInstanceDir::Generation>&,constPassenger::AccountsDatabasePtr&,conststd::string&,constPassenger::AnalyticsLoggerPtr&,int,conststd::string&)'(Pool.h:1078)
in'Server::Server(Passenger::FileDescriptor,pid_t,conststd::string&,bool,conststd::string&,conststd::string&,conststd::string&,conststd::string&,unsignedint,unsignedint,unsignedint,unsignedint,constPassenger::VariantMap&)'(HelperAgent.cpp:241)
in'intmain(int,char**)'(HelperAgent.cpp:344)
[WedAug3114:47:232011][error]***Passengercouldnotbeinitializedbecauseofthiserror:UnabletostartthePhusionPassengerwatchdogbecauseitencounteredthefollowingerrorduringstartup:UnabletostartthePhusionPassengerhelperagent:itseemstohavecrashedduringstartupforanunknownreason,withexitcode1
[WedAug3114:47:232011][notice]Apache/2.2.19(Unix)Phusion_Passenger/3.0.8configured--resumingnormaloperations
solutions:
>sudochmoda+x-R/home/luohua/.rvm/rubies/ruby-1.9.2-p290
or
>sudochmod777-R/home/luohua/.rvm/rubies/ruby-1.9.2-p290
addthistomyhttpd.conf
PassengerRuby/usr/bin/ruby
PassengerDefaultUserroot
linktherubyto/usr/bin
>sudoln-s~/.rvm/rubies/ruby-1.9.2-p290/bin/ruby/usr/bin/ruby
AddonemoreVirtualhostandvisitourrailsapplication
<VirtualHost*:80>
ServerNamewww.sillycat.com
DocumentRoot/opt/work/projectname/public
<Directory/opt/work/projectname/public>
Allowfromall
Options-MultiViews
</Directory>
</VirtualHost>
Icommentsthefollowinglinesinhttpd.conf:
#<Directory/>
#OptionsFollowSymLinks
#AllowOverrideNone
#Orderdeny,allow
#Denyfromall
#</Directory>
Afterallthesedone,Icanvisithttp://www.sillycat.comandgetthepages.
Thatisnotgoodwayforrails,becauseIhavesomeotherapplicationsonapache,andIdonotwantthisapplicationtaketheROOT
contentpath.
SoIwillmakeallthestaticthingsinhtdocdirectory/opt/tools/httpd/htdocs
<VirtualHost*:80>
ServerNameud1129.chinaw3.com
DocumentRoot/opt/tools/httpd/htdocs
<Directory/opt/tools/httpd/htdocs>
Allowfromall
</Directory>
</VirtualHost>
linkmyprojecttothehtdocsdirectory
>sudoln-s/opt/work/projectname/public/opt/tools/httpd/htdocs/projectname
<VirtualHost*:80>
ServerNameud1129.chinaw3.com
DocumentRoot/opt/tools/httpd/htdocs
<Directory/opt/tools/httpd/htdocs>
Allowfromall
</Directory>
RailsBaseURI/projectname
<Directory/opt/tools/httpd/htdocs/projectname>
Options-MultiViews
</Directory>
</VirtualHost>
Tips:Inthisway,wacanmakemultirailsapplications.
<VirtualHost*:80>
....
RailsBaseURI/app1
RailsBaseURI/app2
RailsBaseURI/app3
</VirtualHost>
copyallthestaticthingstohtdocs/assetdirectory
>sudocp/opt/work/projectname/app/assets/images/opt/tools/httpd/htdocs/assets
>sudocp/opt/work/projectname/app/assets/javascripts/opt/tools/httpd/htdocs/assets
>sudocp/opt/work/projectname/app/assets/stylesheets/opt/tools/httpd/htdocs/assets
Ok,done,visithttp://www.sillycat.com/projectname
references:
http://serdaryildirim.net/ruby-on-rails/installing-passenger.html
http://stackoverflow.com/questions/4946426/getting-rails-3-and-passenger-to-work-on-centos-5-4-apache-error
http://www.modrails.com/documentation/Users%20guide%20Apache.html