Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the website unknown directive cannot be opened due to a problem with the Nginx configuration file?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report