Question

Sites-Enabled for Unicorn+Nginx with Rails

Hi, I have a problem with Rails configuration and setup on server.

I have Rails application, and I hosted it using Unicorn and Nginx, but now I can’t access to application. I did pull origin master and I pulled the latest changes but I also did sudo service nginx stop. Now when I did ngnix start I am getting an error: nginx: [emerg] unknown directive “rails_env” in /etc/nginx/sites-enabled/default:10

My default file is:

server {

        listen 80 default_server;

        listen [::]:80 default_server ipv6only=on;



        server_name example.com;

        rails_env   production;

        root         /home/rails/public;



        # redirect server error pages to the static page /50x.html

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

}

Unicorn is running.

Any help please,

Bojan


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.

But I am using unicorn ??

I don’t have Passenger instaled.

How I can to fix it without install passenger?

nginx: [emerg] unknown directive "rails_env" in /etc/nginx/sites-enabled/default:10

rails_env is not a valid Nginx directive by default. It is part of Phusion Passenger. It’s an alias for passenger_app_env Do you have Passenger installed?

Enable it for your server block by adding:

passenger_enabled on;