Search code examples
ruby-on-railsapachepassenger

rails deployment: passenger won't read the public directory


I am trying to deploy a rails application to a RedHat server (rvm,apache). I have no root account, but the Server Host tries to let me do as much as possible through sudo and acls. They don't offer me an applicaion user but install rvm and passenger for all users. So I try and let the application run as apache-user. I am familiar with deploying rails applications. Thats all about the preconditions.

The problem is, that passenger won't read the public directory. Therefor the necessary environment variables are not set. When I set them directly in the ruby files for debugging purposes, the application runs, but still without the assets lying precompiled under public/assets.

What I found is, that the rails directory belonged to my user, so I let them correct that to the user/group apache:apache.

When I restart apache (sudo apachectl restart) I get:

root      5177  0.0  0.2 227884 10760 ?        Ss   Oct27   0:01 /usr/sbin/httpd -k start
apache   25813  0.0  0.2 382060 10488 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25814  0.0  0.2 382060 10604 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25815  0.0  0.2 382060 10604 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25816  0.0  0.2 382060 10604 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25817  0.0  0.2 382060 11232 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25818  0.0  0.2 382060 10468 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25820  0.0  0.2 382060 10604 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25826  0.0  0.2 382060 10604 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25932  0.0  0.2 382060 10468 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25950  0.0  0.2 382060 10468 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start
apache   25951  0.0  0.2 382060 10468 ?        Sl   09:33   0:00 /usr/sbin/httpd -k start

and

    root     25791  0.0  0.1 427572  4148 ?        Ssl  09:33   0:00 Passenger watchdog
root     25794  0.0  0.2 995708 10624 ?        Sl   09:33   0:00 Passenger core                                                      
nobody   25799  0.0  0.1 438064  4284 ?        Sl   09:33   0:00 Passenger ust-router                                                      
kosven   25846  2.8  2.4 316780 97084 ?        Sl   09:33   0:02 Passenger AppPreloader: /var/www/html/rails_app/                                              
kosven   25943  0.0  2.3 386332 91060 ?        Sl   09:33   0:00 Passenger RubyApp: /var/www/html/rails_app/ (production) 

Could this be the reason, why passenger does not serve files from public directory (rails_app/public)?

Thanks a lot in advance, McS


Solution

  • Finally found it, after I was able to edit the corresponding the apache config:

    The DocumentRoot was not set. What a bloody silly mistake...

    So the right configuration looks as follows:

    <VirtualHost my.stillsecrethost.com:80>
            DocumentRoot /var/www/html/rails_app/public
            RailsEnv production
            PassengerAppRoot /var/www/html/rails_app/
            <Directory /var/www/html/rails_app/public >
                Allow from all
                AllowOverride all 
                Options -MultiViews
            </Directory>
    </VirtualHost>
    

    Thanks McS