nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf
时间: 2023-11-14 13:33:52 浏览: 299
Nginx反向代理proxy_cache_path directive is not allowed错误解决方法
This error message indicates that there is a syntax error in the nginx configuration file located at `/etc/nginx/nginx.conf`. Specifically, the error is caused by a "server" directive being placed in the wrong location.
The "server" directive is used to define the configuration for a particular virtual server in nginx. It should be placed within a "http" block, which defines the global configuration for the nginx server. If the "server" directive is placed outside of a "http" block, nginx will not be able to parse the configuration file and will generate the error message you are seeing.
To resolve this error, you should check your nginx configuration file and make sure that all "server" directives are placed within a "http" block. Once you have corrected the syntax error, you can reload the nginx configuration using the command `sudo service nginx reload` to apply the changes.
阅读全文