I followed line by line in this tutorialto setup my own production server.
After Nginx is installed and up and running, I followed the instruction to modified nginx.conf:
Find the following lines, and uncomment them at /etc/nginx/nginx.conf:
# Phusion Passenger
# Uncomment it if you installed ruby-passenger or ruby-passenger-enterprise
When I run:
in terminal give me:
My ruby on the server is at
I am using rvm, and the rvm wrappers location is correct. However, when I run a test using
sudo nginx -t
The system throws this error:
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:67
nginx: configuration file /etc/nginx/nginx.conf test failed
I have searched on google, but somehow all solutions direct me to reinstall nginx with passenger module.
But passenger module have already been installed by following the tutorial.
How can I fix this? Can anyone help?
Interesting. What if you comment out the
passenger_root line? Does
sudo nginx -t then give you an error on
Also, maybe check dpkg to see if the two packages are installed. This is what I get from running
dpkg -l nginx and
dpkg -l passenger:
$ dpkg -l nginx-full Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=============================-===================-===================-================================================================ ii nginx-full 1:1.6.2-184.108.40.206~tr i386 nginx web/proxy server (standard version) $ dpkg -l passenger Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=============================-===================-===================-================================================================ ii passenger 1:4.0.56-1~trusty1 i386 Rails and Rack support for Apache2 and Nginx
If so, I'm guessing that maybe the passenger Ubuntu package didn't get installed and maybe only nginx-full.
You are right Chris,
I have similar message as yours. I will uninstall them and try again. So, the tutorial need to be updated.
In the gorails' tutorial, the code is:
sudo apt-get install nginx-full passenger
but on the official tutorial is:
sudo apt-get install nginx-extras passenger
Thanks for the heads up! I guess they updated their tutorial and I didn't notice.
I am having similar issues and was unable to solve by following this thread. I am also using rvm, and ruby 2.1.5.
The path to my ruby
Tests seem to pass ```sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
However restarting nginx fails
```service nginx restart
- Restarting nginx nginx [fail] ```
I have my /etc/nginx/nginx.conf set up for passenger below
```# Phusion Passenger config
# Uncomment it if you installed passenger or passenger-enterprise
# passenger_ruby /home/deploy/.rvm/rubies/ruby-2.1.5/bin/ruby;
if I uncomment the first 'passenger_ruby' and run 'sudo nginx -t' ```nginx: [emerg] "passenger_ruby" directive is duplicate in /etc/nginx/nginx.conf:65 nginx: configuration file /etc/nginx/nginx.conf test failed
When I visit the site in a browser I get a 403 forbidden. Sorry this is a lot but I have been struggling with this for a while so I wanted to provide any information I thought may be useful to help solve this. Thanks for any help you can provide!
Hmm, sounds like something wrong there with the config. You definitely just want one line that says
passenger_ruby and it should point to the wrapper version of it, not the same as
which ruby outputs.
As far as what to check next, look at /var/log/nginx/error.log and see if there is anything in that file (or other files in the same folder) to see what it says when you get the 403. That will probably give you the best idea of what's wrong.
Figure this out, figured I should post in case someone has similar issues. Looking at the logs as you mentioned led me to the answer. The error log showed the following:
```015/01/14 08:50:38 [error] 18547#0: *1 directory index of "/home/deploy/myApp/current/public/" is forbidden, client: 01.23.45.567, server: myApp.com, request: "GET / HTTP/1.1", host: "myApp.com"
I had to do a couple things: * change permissions `chmod -R 775 /var/log/nginx/` * change ownership `chown -R deploy /var/log/nginx/` * use `sudo service nginx start` to start the server instead of `service nginx start` Thanks for the help Chris, I was really struggling with this.
That would do it! Sometimes the file permissions or ownership will do that. I've often accidentally run a command as sudo without realizing it would change ownership of my app files and all of a sudden Nginx can't read the Rails app anymore.
Thanks for sharing your solution! :)