1
votes

I'm trying to deploy a rails application to a Ubuntu server running passenger and nginx. The server was operational for about a year on ruby 1.8, but I recently upgraded to 1.9.3 (this time using RVM) and as a result had to reinstall everything. I am currently running into two problems:

403 forbidden error

I was able to start the nginx server, but when I try to access the rails application, I receive a 403 Forbidden error that reads:

*2177 directory index of "/srv/myapp/public/" is forbidden

I did some looking around in the nxinx help docs and made sure that the /srv/myapp/ directory has the proper permissions. It is owned by a deploy user that owns the worker process of nginx, and is set chmod 755.

Nginx and Passenger installation problems

When I restart the nginx server, I also receive another error in indicating a problem with my phusion passenger installation:

Unable to start the Phusion Passenger watchdog because its executable (/usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/agents/ PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable.

I reinstall the passenger gem from my non-root (but sudo enabled) user, and reinstall nginx using rvmsudo passenger-install-nginx-module, but then I get this error repeatedly:

Your RVM wrapper scripts are too old. Please update them first by running 'rvm get head && rvm reload && rvm repair all'.

I performed the RVM reload (both with rvmsudo and without) and the error still appears. I tried performing the nginx install without rvmsudo, but ran into permissions problems because I couldn't edit the /opt/nginx/ directory (where I have nginx installed). Now I don't even get that far, because the installer fails to pass the required software check.

Background information

This is what my nginx process currently looks like:

  PID  PPID USER     %CPU    VSZ WCHAN  COMMAND
10174     1 root      0.0  18480 ?      nginx: master process /opt/nginx/sbin/nginx
29418 10174 deploy    0.3  18496 ?      nginx: worker process
29474 12266 1001      0.0   4008 -      egrep (nginx|PID)

My installation process

I've been documenting my installation process in a step-by-step guide for further reference. Please take a look to see how I have my new installation set up.

1

1 Answers

0
votes

Try to reinstall all your environment following this guide and put your Rails application on /var/rails/your_app_dir with this permisions:

sudo chown deployment_user:www-data -R /var/rails/your_app_dir

Use this nginx.conf example to put all pieces together:

user  www-data;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5;
    passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p195/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';


    log_format gzip '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent" "$gzip_ratio"';

    access_log  logs/access.log  gzip  buffer=512k;

    server_names_hash_bucket_size  64;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    ##
    # Virtual Host Configs
    ##
    #include /opt/nginx/conf/*.conf;
    include /opt/nginx/conf/sites-enabled/*;
}