Modify the default port of nginx

First find where the configuration file is

whereis nginx.conf

whereis nginx.conf

You can look through these directories to see where the configuration files are. The correct directory on my side is /etc/nginx

Second find the real configuration file

cd to the /etc/nginx directory
ls

When I opened it, I was stunned. Where is the listen 80 line?
nginx.conf

But don't worry, listen 80 is definitely there, but it's not there. Look, isn't there an include file? Not sure in there.

OK, then go and see what's in the sites-enabled folder
ll

Well, this file points to the site-available/default
default file again. Once opened, um... yes it is
default file

But make a good habit of backing up before modifying

cp default default_backup

Generally, 80 is changed to 81. In fact, it is also possible to change other things.
The next step is to restart nginx. But you will find that nginx cannot be accessed, that is because port 81 is not open, you can refer to my other blog post Modifying the port of the remote server

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326605382&siteId=291194637