I am going through How To Set Up nginx Virtual Hosts (Server Blocks) on CentOS 6.
I’ve previously set up a LEMP stack and moved my web root to /var/www. That works correctly.
On step 5 of the tutorial, I get an error when restarting nginx. I run sudo systemctl restart nginx, and when I do so I get the following error: Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
Running systemctl status nginx.service produces this message: http://hastebin.com/fuwovafeya.avrasm
I’ve double-checked that nginx has access to read and write the files referenced in the tutorial. When I remove virtual.conf, the server starts normally. Here’s my virtual.conf: http://hastebin.com/ihidaqehit.avrasm
Any thoughts on what I might be doing wrong here? Thanks in advance for your help!
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!
Looking at the output of systemctl status nginx.service shows that the command:
nginx -t -c /etc/nginx/nginx.conf
is exiting with a non-0 status which indicates a problem. Run that command on it’s own and it should tell you where the problem in your configuration is located. For instance, I just purposely put a typo in my /etc/nginx/sites-enabled/default file. This is the output of the command:
# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unexpected end of file, expecting "}" in /etc/nginx/sites-enabled/default:113
nginx: configuration file /etc/nginx/nginx.conf test failed
It should tell you exactly what line the problem is at. In this case, it is on line 113.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.