Passenger offline work, but Passenger Module for Apache does not

I have a RoR web application that I am trying to serve using Passenger on Apache. It is strange that I can access the web application if I use the Standalone Passenger, but I cannot access the web application using Apache with the Passenger module.

The passenger module seems to be working, as evidenced by the fact that I can start Apache without errors and that Passenger status returns the following:

----------- General information ----------- max = 6 count = 0 active = 0 inactive = 0 Waiting on global queue: 0 ----------- Application groups ----------- 

When I try to access a web application, I get a list of public folder directories.

Here is my virtual hosts file:

 <VirtualHost *:80> ServerAdmin smith@example.com DocumentRoot /home/smith/www/dashboard/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/smith/www/dashboard/public> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

I have the following at the end of my apache2.conf file:

 LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger 3.0.11/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11 PassengerRuby /usr/bin/ruby1.8 

I am pulling my hair, trying to figure it out. Thank you for helping with this.

Thanks.

+4
source share
1 answer

After several weeks of trial and error, I was finally able to fix this with RTFM. I am surprised that there were no answers to my question about Stackoverflow, and I could not find other articles elsewhere that helped me in my question. This issue should affect everyone who deploys a RoR application using Capistrano on a Linux server running Apache2 and Passenger.

I have Capistrano deploying an application to / home / smith / www / dashboard that creates the current folder, symbolically linking to releases /

The passenger must find config / environment.rb to launch the Rails application. By default, Phusion Passenger assumes that the application root directory is the parent directory of the public directory. See: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerAppRoot

The problem is that when using Capistrano by default, it deploys the application to

/ main / blacksmith / WWW / dashboard / current /

Thus, by default, Passenger defines the path:

/home/smith/www/dashboard/config/environment.rb

Passenger provides the ability to set the PassengerAppRoot configuration parameter in the Apache virtual host file as follows:

PassengerAppRoot / home / smith / www / dashboard / current

This allows the Passenger to correctly find the config / environment.rb file:

PassengerAppRoot / home / scervera / www / dashboard / current / config / environment.rb

Here is the rest of my virtual host file:

 <VirtualHost *:80> ServerName www.example.com DocumentRoot /home/smith/www/dashboard/current/public <Directory /home/smith/www/dashboard/current/public> Options FollowSymLinks AllowOverride none Order allow,deny Allow from all </Directory> PassengerAppRoot /home/smith/www/dashboard/current </VirtualHost> 

There may be other ways to fix this, but I think this is “by the book.”

+6
source

Source: https://habr.com/ru/post/1396075/


All Articles