You are not logged in.

#1 2013-07-03 22:13:00

rwd
Member
Registered: 2009-02-08
Posts: 664

[SOLVED]Ruby on Rails won't run with apache/passenger

Hi I want to run Redmine, a Ruby on Rails application, on a personal server using MariaDB as the database and Apache with the Phusion Passenger module as the application platform. So far I am able to run Redmine with the default WeBrick server, but if I try to run it via Apache (http://192.168.1.5/redmine) I just get the directory index of  /usr/share/webapps/redmine. I've been running various php webapps using this apache installation without issues but my unfamiliarity with Ruby on Rails makes me unsure how to fix this. If I create a Ruby on Rails test  application as described at https://wiki.archlinux.org/index.php/Ru … figuration I get the same issue.

Using the arch wiki articles on Ruby on Rails and Redmine, This is basically how I installed things:

$ yaourt -S ruby1.9 rubygems1.9 nodejs redmine
# gem-1.9 install rails
# gem-1.9 install passenger

/opt/ruby-1-9/ and subfolders ended up having no read/exexute permissions for 'other', probably because of my umask settings, so I changed the permissions, also because apache runs as user/group 'apache'.

Ran the script that installs the passenger apache module:

# /opt/ruby1.9/bin/passenger-install-apache2-module

added to httpd.conf:

(...)
     LoadModule passenger_module /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
(...)
PassengerRoot /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /opt/ruby1.9/bin/ruby

ServerName arch-server
DocumentRoot /usr/share/webapps
<Directory "/usr/share/webapps">
	 # This relaxes Apache security settings.
	 AllowOverride all
	 #
	 Order allow,deny
	 Allow from all
	 # MultiViews must be turned off.
	 Options -MultiViews
</Directory>

I checked if the passenger module is loaded, and judging from /var/log/httpd/error_log that seems the case:

[ 2013-07-03 22:52:22.8947 28902/b7407700 agents/Watchdog/Main.cpp:440 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nobody', 'default_python' => 'python', 'default_ruby' => '/opt/ruby1.9/bin/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_instances_per_app' => '0', 'max_pool_size' => '6', 'passenger_root' => '/opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_pid' => '28901', 'web_server_type' => 'apache', 'web_server_worker_gid' => '1001', 'web_server_worker_uid' => '1006' }
[ 2013-07-03 22:52:22.9120 28905/b73bd700 agents/HelperAgent/Main.cpp:555 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.28901/generation-0/request
[ 2013-07-03 22:52:22.9262 28902/b7407700 agents/Watchdog/Main.cpp:564 ]: All Phusion Passenger agents started!
[ 2013-07-03 22:52:22.9266 28910/b71dd700 agents/LoggingAgent/Main.cpp:271 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.28901/generation-0/logging
[Wed Jul 03 22:52:22 2013] [notice] Apache/2.2.24 (Unix) PHP/5.4.16 mod_ssl/2.2.24 OpenSSL/1.0.1e DAV/2 Phusion_Passenger/4.0.5 configured -- resuming normal operations

'apachectl configtest' gives 'Syntax OK'.

I followed the wiki on redmine (https://wiki.archlinux.org/index.php/Redmine), chose to use "bundle install" to install the required gems with only a 'production' environment. What worried me is that those gems are now in /root/.gems while the webserver runs as user 'apache'.

I can run Redmine at 192.168.1.5:3000 without errors using:

# ruby script/rails server webrick -e production

But if I kill it and try via apache http://192.168.1.5/redmine I get a directory content listing.

Last edited by rwd (2013-07-04 21:00:10)

Offline

#2 2013-07-04 12:30:49

markocz
Member
Registered: 2012-07-02
Posts: 3

Re: [SOLVED]Ruby on Rails won't run with apache/passenger

Not sure, but i guess this is what you're looking for. Helped me in my search of clues for similar problem with lighttpd.

Offline

#3 2013-07-04 19:27:07

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: [SOLVED]Ruby on Rails won't run with apache/passenger

markocz wrote:

Not sure, but i guess this is what you're looking for. Helped me in my search of clues for similar problem with lighttpd.

Thanks I'll check it out. Judging from the article it seems that all rails applications need 'RailsBaseURI' set for sub urls- to work. That would explain why even the sample app wouldn't run under passenger.

Last edited by rwd (2013-07-04 19:29:52)

Offline

#4 2013-07-04 20:42:16

rwd
Member
Registered: 2009-02-08
Posts: 664

Re: [SOLVED]Ruby on Rails won't run with apache/passenger

Thanks markocz, my use of sub-url was indeed the problem. With help from the linked article I did the following:

# mkdir /usr/share/webapps/phusion-passenger/
# ln -s /usr/share/webapps/redmine/public /usr/share/webapps/phusion-passenger/redmine
# chown -R root:http /usr/share/webapps/
# chmod -R g+rx /usr/share/webapps/

httpd.conf now looks like this:

(...)
LoadModule passenger_module /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
(...)
PassengerRoot /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /opt/ruby1.9/bin/ruby

ServerName arch-server
DocumentRoot /usr/share/webapps/phusion-passenger
<Directory "/usr/share/webapps/phusion-passenger">
	 # This relaxes Apache security settings.
	 AllowOverride all
	 #
	 Order allow,deny
	 Allow from all
	 # MultiViews must be turned off.
	Options +FollowSymLinks
</Directory>

RailsBaseURI /redmine

<Directory "/usr/share/webapps/phusion-passenger/redmine">
	 Options -MultiViews
</Directory>

Redmine now works via passenger.

Last edited by rwd (2013-07-04 20:59:40)

Offline

Board footer

Powered by FluxBB