Sites-Enabled for Unicorn+Nginx with Rails

December 30, 2014 891 views

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;


        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,


2 Answers
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;

But I am using unicorn ??

I don't have Passenger instaled.

How I can to fix it without install passenger?

Have another answer? Share your knowledge.