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

Win2008 R2 mysql 5.5 zip format mysql installation and configuration

Win2008 R2 zip format mysql installation and conf...

Implementation of waterfall layout in uni-app project

GitHub address, you can star it if you like it Pl...

Two ways to enable firewall in Linux service

There are two ways: 1. Service method Check the f...

CSS3 realizes the childhood paper airplane

Today we are going to make origami airplanes (the...

Unicode signature BOM detailed description

Unicode Signature BOM - What is the BOM? BOM is th...

How to solve the problem that Docker container has no vim command

Find the problem Today, when I tried to modify th...

Thoughts on copy_{to, from}_user() in the Linux kernel

Table of contents 1. What is copy_{to,from}_user(...

Introduction to keyword design methods in web design

Many times, we ignore the setting of the web page ...

HTML code that can make IE freeze

We simply need to open any text editor, copy the f...

How to configure Bash environment variables in Linux

Shell is a program written in C language, which i...

How to use Nginx proxy to surf the Internet

I usually use nginx as a reverse proxy for tomcat...

VUE render function usage and detailed explanation

Table of contents Preface The role of render Rend...

Tutorial on installing DAMO database on Centos7

1. Preparation After installing the Linux operati...

A detailed introduction to the Linux directory structure

When you first start learning Linux, you first ne...

How to install mysql5.6 in docker under ubuntu

1. Install mysql5.6 docker run mysql:5.6 Wait unt...