When Nginx is turned on, the port is occupied and prompts: Address already in use

When Nginx is turned on, the port is occupied and prompts: Address already in use

As shown in the figure:

Check port usage:

sudo netstat -apn | grep 80

View the process occupying the port:

ps -ef | grep 3345

From the results, we can see that port 80 is occupied by Nginx itself. You can kill the process and restart Nginx.

sudo kill -9 3345

sudo netstat -apn | grep 80

After successfully killing the process, start Nginx

Start Nginx successfully. Enter the IP address of the system where Nginx is located in the browser to verify whether Nginx is started successfully.

The following describes how to start, stop, and restart Nginx.

start up

Startup code format: nginx installation directory address -c nginx configuration file address

For example:

[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

stop

There are three ways to stop nginx:

Stop calmly

1. Check the process number

[root@LinuxServer ~]# ps -ef|grep nginx 

2. Kill the process

[root@LinuxServer ~]# kill -QUIT 2072 

Quick Stop

1. Check the process number

[root@LinuxServer ~]# ps -ef|grep nginx 

2. Kill the process

[root@LinuxServer ~]# kill -TERM 2132
or [root@LinuxServer ~]# kill -INT 2132

Force Stop

[root@LinuxServer ~]# pkill -9 nginx

Restart

1. Verify whether the nginx configuration file is correct

Method 1: Enter the nginx installation directory sbin and enter the command ./nginx -t

The following shows that nginx.conf syntax is ok

nginx.conf test is successful

This indicates that the configuration file is correct!

Method 2: Add -t before the startup command -c

2. Restart Nginx service Method 1: Enter the nginx executable directory sbin and enter the command ./nginx -s reload

Method 2: Find the current nginx process number, and then enter the command: kill -HUP process number to restart the nginx service

Summarize

The above is what I introduced to you about the prompt that the port is occupied when starting Nginx: Address already in use. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed explanation of nginx signal set case
  • Introduction to Nginx log management
  • Detailed explanation of CentOS configuration of Nginx official Yum source
  • Install multiple versions of PHP for Nginx on Linux
  • Detailed tutorial on installing PHP and Nginx on Centos7
  • A universal nginx interface to implement reverse proxy configuration
  • Solve the problem of refreshing blank when deploying Vue project nginx to non-root directory
  • How to install Nginx and configure multiple domain names
  • Solution to the problem that docker nginx cannot be accessed after running
  • How to redirect to https through nginx load balancing
  • Nginx signal control

<<:  Implementation of vscode custom vue template

>>:  MySql 5.6.35 winx64 installation detailed tutorial

Recommend

Detailed explanation of non-parent-child component communication in Vue3

Table of contents First method App.vue Home.vue H...

Summary of Mysql exists usage

Introduction EXISTS is used to check whether a su...

Markup language - CSS layout

Click here to return to the 123WORDPRESS.COM HTML ...

Use pictures to realize personalized underline of hyperlinks

Don't be surprised if you see some kind of und...

Solution for installing opencv 3.2.0 in Ubuntu 18.04

Download opencv.zip Install the dependencies ahea...

How to implement vue page jump

1. this.$router.push() 1. Vue <template> &l...

Detailed explanation of js event delegation

1. Each function is an object and occupies memory...

Deep understanding of JavaScript syntax and code structure

Table of contents Overview Functionality and read...

A commonplace technique for implementing triangles using CSS (multiple methods)

In some interview experiences, you can often see ...

Common problems and solutions during MySQL MGR construction

Table of contents 01 Common Faults 1 02 Common Fa...

Why should you be careful with Nginx's add_header directive?

Preface As we all know, the nginx configuration f...

Centos7 mysql database installation and configuration tutorial

1. System environment The system version after yu...

In-depth understanding of Vue's plug-in mechanism and installation details

Preface: When we use Vue, we often use and write ...