Sometimes when you start an application, you will find that the port is occupied, or that some of the ports are not being used but are found to be open. At this point we want to know which application/process is using the port.
CentOS can be viewed with netstat or lsof, and can be viewed with netstat under Windows, but with different parameters
Linux:
Netstat-nap #会列出所有正在使用的端口及关联的进程/Application
Lsof-i:p Ortnumber #portnumber要用具体的端口号代替 that can be listed directly by the port listening to use process/application
First, check which process the port is occupied by
The code is as follows |
Copy Code |
Netstat-lnp|grep #88请换为你的apache需要的端口, such as: |
SSH executes the above command to see which process the 88 port is being used by. In the following figure, the process number is 1777.
Second, view the process details
PS 1777
SSH executes the above command. View the program detail path for the corresponding process number. The following figure.
Third, kill the process, restart Apache
The code is as follows |
Copy Code |
Kill-9 1777 #杀掉编号为1777的进程 (Please enter according to the actual situation) Service httpd Start #启动apache
|
SSH executes the above command, and if there is no problem, Apache will start normally.
Windows system:
Netstat-nao #会列出端口关联的的进程号, which task can be viewed through Task Manager
The last column of the program PID, and then through the tasklist command: tasklist | Findstr 2724
And then end the program with mission management.