Nginx unknown directive for passenger_root

Papouche Guinslyzinho picture Papouche Guinslyzinho · Feb 17, 2014 · Viewed 21.3k times · Source

I'm running into an error when I try to restart the server. I don't know how to fix this.

deploy@user:~$ sudo nginx -s reload
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:66

I added these lines to the nginx configuration file '/etc/nginx/nginx.conf'

passenger_root /home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37;
passenger_ruby /home/deploy/.rvm/gems/ruby-2.0.0-p353/wrappers/ruby;

Answer

Adam picture Adam · Apr 18, 2014

I ran into the same thing. I had accidentally installed the nginx-extras package that is normally provided by Ubuntu, rather than the one provided by Phusion Passenger's repository. The Passenger package has Passenger compiled with Nginx as a module, while the other package does not.

The solution is to add Phusion Passenger's apt repository, then install the nginx-extras package from it. The method of doing this differs slightly depending on your Linux distro and version so you should read the documentation first: https://www.phusionpassenger.com/library/install/nginx/apt_repo/

If reading the documentation is a problem for you then you can try the commands I used to add the repository and install the nginx-extras package from it.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y nginx-extras