Proper Passenger + Apache Permissions to fix error "No such file or directory – config/environment.rb"

acoustic_north asked:

I am having a problem with Passenger not being able to start due to an apparently common issue in which Passenger claims: No such file or directory – config/environment.rb.

I have searched the web high and low and this appears to be a permissions related issue. It is my understanding that Passenger runs as the owner of and config/environment.rb file. In my case this owner is “admin”. I am running the app root in the home directory of the admin user. So I believe I have the correct permissions set using:
sudo chown -R admin:admin /home/admin/www
sudo chmod -R 755 /home/admin/www

where the app root is located at:

Here is my virtual server config file:

 <VirtualHost *:80>
    DocumentRoot /home/admin/www/app/current/public
    <Directory /home/admin/www/app/current/public>
    Options FollowSymLinks
    AllowOverride none
    Order allow,deny
    Allow from all
    PassengerResolveSymlinksInDocumentRoot on
    RailsBaseURI /
    PassengerAppRoot /home/admin/www/app
    RailsEnv production   
    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/access.log combined

I am running Ubuntu 12.0.4, Rails 3.2.8, Ruby 1.9.3, Passenger 3.0.18, Apache 2

Thanks for your help.

My answer:

Your PassengerAppRoot is wrong. You specified /home/admin/www/app but your app is actually in /home/admin/www/app/current. This is why Passenger can’t find it.

The resolution is to fix the configuration.

    PassengerAppRoot /home/admin/www/app/current

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.