Detailed explanation on how to modify the default port of nginx

Detailed explanation on how to modify the default port of nginx

First find out 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 here is /etc/nginx

Next, find the real configuration file

cd to the /etc/nginx directory

ls

When I opened it, I was confused. Where was the line "listen 80"?

nginx.conf

But don’t worry, listen 80 is definitely there, it’s just not included here. Look, isn't there an include file? Who knows in there.

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

ll

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

default file

But develop a good habit and back up before modifying

cp default default_backup
Errata: This should be cp default ../default_backup, otherwise when including, the * in this directory will be used, and the backup will also be treated as a configuration file

Generally, 80 is changed to 81, but it can be changed to something else.
The next step is to restart nginx. But you will find that nginx cannot access it, that is because port 81 is not open, you can refer to my other blog post Remote Server Modification Port

This is the end of this article on how to modify the default port of nginx. For more information about how to modify the default port of nginx, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to modify the default port 80 in nginx

<<:  Implementation of dynamic rem for mobile layout

>>:  The iframe refresh method is more convenient

Recommend

Summary of 10 advanced tips for Vue Router

Preface Vue Router is the official routing manage...

Detailed explanation of built-in methods of javascript array

Table of contents 1. Array.at() 2. Array.copyWith...

Universal solution for MySQL failure to start under Windows system

MySQL startup error Before installing MySQL on Wi...

How to pop up a temporary QQ dialog box to chat online without adding friends

In fact, this is very simple. We add an a tag to ...

MySQL database operations (create, select, delete)

MySQL Create Database After logging into the MySQ...

Vue3 manual encapsulation pop-up box component message method

This article shares the specific code of Vue3 man...

Summary of Linux commands commonly used in work

Use more open source tools such as docker and kub...

How to regularly clean up docker private server images

Using CI to build docker images for release has g...

Tips for using top command in Linux

First, let me introduce the meaning of some field...

Detailed explanation of HTML table inline format

Inline format <colgroup>...</colgroup>...

jQuery plugin to achieve code rain effect

This article shares the specific code of the jQue...

jQuery realizes the shuttle box effect

This article example shares the specific code of ...

Linux kernel device driver kernel linked list usage notes

/******************** * Application of linked lis...