Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Passenger problem with Apache2

Tags:

I'm trying to setup a ruby on rails server on ubuntu10.10 with apache2 and mod_rails (Phusion Passenger).

I already installed ruby 1.9.2-p0 and rails 3.0.8 and installed Passenger with the passenger-install-apache2-module and the passenger gem (v3.0.7).

It then tells me to add 3 lines to my Apache config file. So I added these lines to '/etc/apache2/apache2.conf':

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7 PassengerRuby /usr/local/bin/ruby 

And I edited my '/etc/apache2/httpd.conf' and added:

NameVirtualHost *:80  <VirtualHost *:80> ServerName 192.168.0.2 DocumentRoot /var/www/webop/public  <Directory /var/www/webop/public> Allow from all Options -MultiViews </Directory> </VirtualHost> 

I also found out that the file mod_passenger.so in /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/ actually does not exist, its name is mod_passenger.c. But I don't get any errors from that.

The server should only be accessible through a LAN. When I access the server I see all the files and directories in the public folder of my app but the app itself does not get started.

When I restart apache it tells me that mod_rails is already loaded so I guess that passenger is running but I can't figure out why it doesn't start my app!

Thanks in advance!

like image 475
Andre Schweighofer Avatar asked Jun 11 '11 15:06

Andre Schweighofer


People also ask

How do I know if my Phusion Passenger is running?

passenger-status looks at the current status of a Phusion Passenger installation. It will locate Phusion Passenger automatically if it is running and will give you a list of instances if there is more than one Phusion Passenger instance running.

How do I view passenger logs?

Location of the log file By default, the Passenger log file is the global (not the per-vhost) Apache error log file. This is typically located in /var/log/apache2/error_log . You can find out the exact location of the error log by running passenger-config --detect-apache2 .


2 Answers

The reason mod_passenger.so does not exist is because you haven't installed the Apache module. Execute:

passenger-install-apache2-module 

This will create the mod_passenger.so file inside your gem directory, and give you three lines to copy into your apache2.conf file.

The passenger module is installed in your current gemset so you shouldn't get any conflicts between projects. You can use any compatible version of Ruby, and any gemset you like, via RVM, and possibly also RBENV. This makes for a nice easy upgrade path from one version of Ruby to the next.

like image 160
superluminary Avatar answered Oct 19 '22 21:10

superluminary


I finally figured out what the problem was: I messed up my ruby installation.

In /usr/local/ I had ruby1.9.2-p0 installed (which was the version I wanted to use) but in /usr/ i had ruby1.8.7 installed.

Passenger was confused which ruby version to use so I changed the LoadModule, PassengerRoot and PassengerRuby paths within apache2/mods-enabled/passenger.load and .config to the correct paths and it finally worked! Both files were created automatically which also caused the problem of a redefinition: On apache startup there was a warning 'mod_passenger already loaded'. So I removed

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7 PassengerRuby /usr/local/bin/ruby 

from the apache config and the warning disappeared!

Probably this will help someone else some day!

like image 23
Andre Schweighofer Avatar answered Oct 19 '22 23:10

Andre Schweighofer