How to solve the problem that the port is occupied when opening Nginx

WBOY
Release: 2023-05-20 17:46:06
forward
5478 people have browsed it

As shown in the figure:

How to solve the problem that the port is occupied when opening Nginx

Check the port occupancy:

sudo netstat -apn | grep 80

How to solve the problem that the port is occupied when opening Nginx

Check the process occupying the port:

ps -ef | grep 3345

How to solve the problem that the port is occupied when opening Nginx

It can be seen from the results 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

How to solve the problem that the port is occupied when opening Nginx

After successfully killing the process, start nginx

How to solve the problem that the port is occupied when opening Nginx

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

How to solve the problem that the port is occupied when opening Nginx

The following describes how to start, stop and restart nginx

Start

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
Copy after login

Stop

There are three ways to stop nginx:

Easy stop

 1. Check the process number

[root@linuxserver ~]# ps -ef|grep nginx
Copy after login
Copy after login

How to solve the problem that the port is occupied when opening Nginx

 2 , Kill the process

[root@linuxserver ~]# kill -quit 2072
Copy after login

How to solve the problem that the port is occupied when opening Nginx

##Quick stop

1. Check the process number

[root@linuxserver ~]# ps -ef|grep nginx
Copy after login
Copy after login

How to solve the problem that the port is occupied when opening Nginx2. Kill the process

[root@linuxserver ~]# kill -term 2132
或 
[root@linuxserver ~]# kill -int 2132
Copy after login

How to solve the problem that the port is occupied when opening NginxForce stop

[root@linuxserver ~]# pkill -9 nginx
Copy after login

Restart

1. Verify whether the nginx configuration file is correct

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

See the following display nginx.conf syntax is ok

nginx. conf test is successful

means the configuration file is correct!

How to solve the problem that the port is occupied when opening NginxMethod 2: Add -t before the start command -c

How to solve the problem that the port is occupied when opening Nginx2. Restart the nginx service. Method 1: Enter the nginx executable directory sbin and enter the command ./nginx -s reload

How to solve the problem that the port is occupied when opening NginxMethod 2: Find the current nginx process number, and then enter the command: kill -hup process No. to restart nginx service

The above is the detailed content of How to solve the problem that the port is occupied when opening Nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!