While still learning a lot about NGinx (many more questions to come…) I am confused abou the output of the “nginx -t” command. When running just like that it gives me the following error messages:
[warn] 767805#767805: the “user” directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
[emerg] 767805#767805: open() “/etc/nginx/conf.d/botblocker-nginx-settings.conf” failed (13: Permission denied) in /etc/nginx/nginx.conf:78
When running “sudo nginx -t” everything looks ok:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Am I supposed to correct something in nginx.conf (line 1 “user www-data;” and 78 “include /etc/nginx/conf.d/*.conf;”)? Is this somewhat normal? Can this be ignored?
Still very new to NGinx obviously so I hope You don’t mind me asking in here…. Thanks in advance for any helpful reply!
This is normal behavior and you don’t need to correct anything in your nginx.conf file. The output you’re seeing is a result of permission issues, specifically because you’re running the command as a regular user instead of a super-user (root).
The errors you’re getting from nginx -t are expected because:
NGINX, when running, needs to be able to read its configuration files. Some of these files, especially those in /etc/nginx/, are owned by the root user and prevent regular users from reading them. When you run nginx -t as a regular user, the command fails because it can’t access /etc/nginx/conf.d/botblocker-nginx-settings.conf, thus the “Permission denied” error.
The “user” directive: The user www-data; directive at the top of your nginx.conf file specifies which user NGINX will run as after it starts up. The master process, which starts everything, needs super-user privileges to drop down to this less-privileged user (www-data). Since you’re not running the command with sudo, you’re not a super-user, so NGINX warns you that the directive will be ignored because you don’t have the permissions to execute it.
When you run sudo nginx -t, you are running the command with super-user privileges. This allows NGINX to bypass the permission restrictions and read all the necessary configuration files, so the test runs successfully.