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

js to achieve a simple carousel effect

This article shares the specific code of js to ac...

Write a shopping mall card coupon using CSS in three steps

Today is 618, and all major shopping malls are ho...

Implementation of Docker packaging image and configuration modification

I have encountered many problems in learning Dock...

Explanation of the process of docker packaging node project

As a backend programmer, sometimes I have to tink...

JavaScript implements draggable progress bar

This article shares the specific code of JavaScri...

Textarea tag in HTML

<textarea></textarea> is used to crea...

Sharing tips on using Frameset to center the widescreen

Copy code The code is as follows: <frameset co...

Ideas and codes for realizing magnifying glass effect in js

This article example shares the specific code of ...

Add ico mirror code to html (favicon.ico is placed in the root directory)

Code: Copy code The code is as follows: <!DOCTY...

ElementUI implements cascading selector

This article example shares the specific code of ...

Commonplace talk about the usage of MYSQL pattern matching REGEXP and like

like LIKE requires the entire data to match, whil...

A brief discussion on the Linux kernel's support for floating-point operations

Currently, most CPUs support floating-point units...

Docker file storage path, get container startup command operation

The container has already been created, how to kn...

Introduction to Linux system swap space

Swap space is a common aspect of computing today,...