Nginx:[emerg] unknown directive “server” in******* Error solution

Nginx:[emerg] unknown directive “server” in*******

Today I used Notepad to edit the nginx.conf file under Windows and save it. An error occurs after starting the server

[emerg] 10352#3232: unknown directive "server" in /nginx-1.8.1/conf/nginx.conf:1

But no problem was found when checking nginx.conf.
Found information online. The conf file was edited with Notepad and saved as containing [BOM]. That's why the error was reported.

Use vscode to change the encoding mode of the file and change it back to UTF-8 encoding:

Insert image description here

ctrl+shift + p Open the dock and find change encode (character encoding)
Then press Enter. There are a lot of lists and select utf-8;

Save and re-upload, nginx -t check passes.

Original address

Guess you like

Origin blog.csdn.net/Yoga99/article/details/125540256