Green
Green

Reputation: 30815

Why `sudo nginx -t` and `nginx -t` return opposite results for the very same file?

These commands return opposite results for nginx.conf - one is failed, another one is successful. Why?

$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Upvotes: 0

Views: 256

Answers (1)

cnst
cnst

Reputation: 27228

nginx: [emerg] open() "/run/nginx.pid" failed (13: Permission denied)

It sounds like the permissions for the pid file (as defined by the pid directive) preclude your normal user from accessing it, thus the test of the configurations appears to fail.

Upvotes: 1

Related Questions