Question

Problem With Home page in ruby on Rails

Hi

I had developed a application in ruby on rails and deployed with the help of this link https://www.digitalocean.com/community/tutorials/how-to-automate-ruby-on-rails-application-deployments-using-capistrano and i have set ruby application correctly ngnix/default.conf file also but when trying to access my application through ip address its showing 404 Not Found in my browser but i have tested with html test page with same path its working fine and this is what my conf files

 server {
    listen       80;
    server_name  xxx.xxx.xxx.xxx;
    root /home/deployer/app-name/current/app/views/sessions/login.html.erb;
    passenger_enabled on;

    #charset koi8-r;
    access_log  /var/log/nginx/alemany.access.log  main;
    error_log /var/log/nginx/alemany.error.log;
    
    #root   /usr/share/nginx/html;
    #index index.php index.html index.htm ;
    
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php-fpm.sock; 
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The root directive shouldn’t point to a specific file. Instead, it should point to the application’s public/ directory. Here is a minimal working example:

 server {
    listen       80;
    server_name  xxx.xxx.xxx.xxx;
    root /home/deployer/app-name/public;
    passenger_enabled on;

    access_log  /var/log/nginx/access.log  main;
    error_log /var/log/nginx/error.log;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }
}

Note that I also removed the location ~ \.php$ section. This is not needed for a Rails application, only PHP one.

For more information, check out this tutorial that walks through setting up Rails and Nginx with Passenger start to finish: