What if the website unknown directive cannot be opened due to a problem with the Nginx configuration file?
This article is to share with you what to do if you can't open the website unknown directive due to a problem with the Nginx configuration file. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The website unknown directive could not be opened due to a problem with the Nginx configuration file
In the afternoon, the cheap hand looked at the nginx configuration file (PS: always can not remember the location / usr/local/nginx/conf/nginx.conf), changed some things slightly, saved and restarted nginx and found that the website could not be opened.
At that time, ping was connected, even vpn was connected, but the website could not be opened. It seems that it must have broken the configuration file of nginx.
After opening the file for a long time, I didn't find any problem.
The following prompt appears when executing / usr/local/nginx/sbin/nginx-t
Nginx: [emerg] unknown directive "Server" in / usr/local/nginx/conf/nginx.conf:55
Nginx: configuration file / usr/local/nginx/conf/nginx.conf test failed
In this way, it is determined that it is the problem of nginx.conf, because I am not familiar with the file structure, so I have to check it carefully against nginx.conf.default. I finally found the problem.
The correct configuration format should be:
Http {server {}}
When I revised it, I deleted the last parenthesis by mistake, which was bound to make a mistake and changed the format to
Http {} server {}
This is bound to go wrong.
Change it back and restart nginx
/ usr/local/nginx/sbin/nginx-s reload
The website is open again.
Thank you for reading! About "due to Nginx configuration file problems can not open the website unknown directive how to do" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!