LinuxDeployRails3withRuby1.9.2 (4) ConfiguretherailsinApache2Changetheconfigurationofapache2 & gt; vihttpd. confLoadModulepassenger_module/home/luohua/. rvm/rubies/rub
Linux Deploy Rails3 with Ruby1.9.2 (4) Configure the rails in Apache2
Change the configuration of apache2
> Vi httpd. conf
LoadModule passenger_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
Try to restart the apache server
> Bin/apachel restart
Error messages:
Httpd: Syntax error on line 423 of/opt/tools/httpd/conf/httpd. conf: API module structure 'passenger _ module' in file/home/luohua /. rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9/gems/passenger-3.0.8/ext/apache2/mod_passenger.so is garbled-expected signature 41503232 but saw 41503230-perhaps this is not apache module DSO, or was compiled for a different Apache version?
Solutions:
That is because I have 2 version of apache2 on my server. I will use the one who compiled pasled.
The compile passenger information:
* Apache 2... found at/usr/bin/httpd
* Apache 2 development headers... found at/usr/sbin/apxs
* Apache Portable Runtime (APR) development headers... found at/usr/bin/apr-config
* Apache Portable Runtime Utility (APU) development headers... found at/usr/bin/apu-config
> Sudo mv/usr/sbin/httpd. bak
> Sudo ln-s/opt/tools/httpd/bin/httpd/usr/bin/httpd
> Sudo mv/usr/sbin/apxs. bak
> Sudo ln-s/opt/tools/httpd/bin/apxs/usr/sbin/apxs
Find the version of apache
> Bin/apachectl-V | grep SERVER_CONFIG_FILE
Located the APXS2
> Export APXS2 =/opt/tools/httpd/bin/apxs
Try to restart the apache again
> Bin/apachel restart
Error message:
[Wed Aug 31 14:47:23 2011] [notice] SIGHUP received. Attempting to restart
* ** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager. h: 220 ):
Cocould not start the spawn server:/home/luohua/. rvm/rubies/ruby-1.9.2-p290: Permission denied (13)
[Pid = 14425 thr = 3086257024 file = ext/apache2/HelperAgent. cpp: 354 time = 14:47:23. 906]: cocould not start the spawn server: write () failed: Broken pipe (32)
In 'passenger: SpawnManager (const std: string &, const boost: shared_ptr &, Const Passenger: AccountsDatabasePtr &, const std: string &, const Passenger: AnalyticsLoggerPtr &, int, const std: string &) '(SpawnManager. h: 540)
In 'passenger: ApplicationPool: Pool (const std: string &, const boost: shared_ptr &, Const Passenger: AccountsDatabasePtr &, const std: string &, const Passenger: AnalyticsLoggerPtr &, int, const std: string &) '(Pool. h: 1078)
In 'server: Server (Passenger: FileDescriptor, pid_t, const std: string &, bool, const std: string &, const std: string &, const std:: string &, const std: string &, unsigned int, const pasned: VariantMap &) '(HelperAgent. cpp: 241)
In 'Int main (int, char **) '(HelperAgent. cpp: 344)
[Wed Aug 31 14:47:23 2011] [error] *** Passenger cocould not be initialized because of this error: Unable to start the Phusion passion watchdog because it encountered the following error during startup: unable to start the Phusion Passenger helper agent: it seems to have crashed during startup for an unknown reason, with exit code 1
[Wed Aug 31 14:47:23 2011] [notice] Apache/2.2.19 (Unix) Phusion_Passenger/3.0.8 configured -- resuming normal operations
Solutions:
> Sudo chmod a + x-R/home/luohua/. rvm/rubies/ruby-1.9.2-p290
Or
> Sudo chmod 777-R/home/luohua/. rvm/rubies/ruby-1.9.2-p290
Add this to my httpd. conf
PassengerRuby/usr/bin/ruby
PassengerDefaultUser root
Link the ruby to/usr/bin
> Sudo ln-s ~ /. Rvm/rubies/ruby-1.9.2-p290/bin/ruby/usr/bin/ruby
Add one more Virtual host and visit our rails application
ServerName www.sillycat.com
DocumentRoot/opt/work/projectname/public
Allow from all
Options-MultiViews
I comments the following lines in httpd. conf:
#
# Options FollowSymLinks
# AllowOverride None
# Order deny, allow
# Deny from all
#
After all these done, I can visit http://www.sillycat.com and get the pages.
That is not good way for rails, because I have some other applications on apache, and I do not want this application take the ROOT
Content path.
So I will make all the static things in htdoc directory/opt/tools/httpd/htdocs
ServerName ud1129.chinaw3.com
DocumentRoot/opt/tools/httpd/htdocs
Allow from all
Link my project to the htdocs directory
> Sudo ln-s/opt/work/projectname/public/opt/tools/httpd/htdocs/projectname
ServerName ud1129.chinaw3.com
DocumentRoot/opt/tools/httpd/htdocs
Allow from all
RailsBaseURI/projectname
Options-MultiViews
Tips: In this way, wa can make multi rails applications.
....
RailsBaseURI/app1
RailsBaseURI/app2
RailsBaseURI/app3
Copy all the static things to htdocs/asset directory
> Sudo cp/opt/work/projectname/app/assets/images/opt/tools/httpd/htdocs/assets
> Sudo cp/opt/work/projectname/app/assets/javascripts/opt/tools/httpd/htdocs/assets
> Sudo cp/opt/work/projectname/app/assets/stylesheets/opt/tools/httpd/htdocs/assets
Author: "A Whip must work hard !"