05aa7ba235753631e1c133cccb3e675bfcbae006
By:
Saphiria

Nginx - Everything is ok / successful

April 30, 2016 750 views
Nginx

Hello,
When I do sudo nginx -t, I get told this:
<^>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful<^>

But, when I do service nginx restart I get:

  • Restarting nginx nginx [fail]

But, when I do sudo service nginx restart I get:

  • Restarting nginx nginx [ OK ]

Lastly, if I do niginx -t without "sudo" I get:
<^>nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2016/04/30 12:11:48 [warn] 16918#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2016/04/30 12:11:48 [emerg] 16918#0: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed<^>

Any thoughts?

1 comment
  • Everything's fine there. For security reasons, everything under /var/log/nginx/ (or /var/log/apache2/ if you use Apache instead) is owned by root and can't be touched by any other user. Hence the "sudo" requirement.

    There's nothing wrong with your configuration.

1 Answer

Answer by user Artelis:

Everything's fine there. For security reasons, everything under /var/log/nginx/ (or /var/log/apache2/ if you use Apache instead) is owned by root and can't be touched by any other user. Hence the "sudo" requirement.

There's nothing wrong with your configuration.

Have another answer? Share your knowledge.