Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to solve the problem that the port is occupied when opening Nginx". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem when opening Nginx when the port is occupied".

As shown in the figure:

View port occupancy:

Sudo netstat-apn | grep 80

View the processes that occupy the port:

Ps-ef | grep 3345

The result shows that port 80 is occupied by nginx itself, so you can kill the process and restart nginx.

Sudo kill-9 3345

Sudo netstat-apn | grep 80

After successfully killing the process, start nginx

Nginx is started 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 the start, stop and restart of 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

Stop it

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

Forced stop

[root@linuxserver] # pkill-9 nginx

Restart

1. Verify that the nginx configuration file is correct

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

See the following display of nginx.conf syntax is ok

Nginx.conf test is successful

Indicates that the configuration file is correct!

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

2. Restart the 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

Thank you for your reading, the above is the content of "how to solve the problem that the port is occupied when opening Nginx". After the study of this article, I believe you have a deeper understanding of how to solve this problem when opening Nginx, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report