如何杀死运行在本地主机端口8080上的Apache/PHP服务器? [英] How to kill Apache / PHP server running on local host port 8080?

查看:117
本文介绍了如何杀死运行在本地主机端口8080上的Apache/PHP服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在运行macOS High Sierra版本10.13.6.

这是在浏览器中加载localhost:8080时得到的: Apache/PHP服务器屏幕截图

我不知道该服务器是如何在此端口上启动的,因为我从未使用过这些技术.我时不时会搞网络开发,但是我不知道服务器启动时我在做什么.我已经研究了如何终止进程,到目前为止,我最接近终止服务器的任务是终止chrome浏览器.我试图找到在端口8080上运行的进程的一些事情:

ps aux | grep 8080
lsof -t -i @localhost:8080
netstat -l -p | grep 8080
lsof -nP -i | grep 8080

我尝试过其他一些看上去相似的东西,但我都无法回忆起.使用lsof命令时,通常必须将sudo放在它们前面,以便显示任何内容.我有时什么也没回来,有时我会得到这样的东西: ps aux输出在Postgres进程所在的地方.

当我找回具有与之关联的PID的进程时,我会尝试使用kill -9 <PID>杀死它们.通常,我必须使用sudo强制执行此操作,因为它给了我一个权限被拒绝的错误(可能不是最佳实践).当我执行此操作时,除杀死最初的进程之后进行搜索时,似乎没有其他进程出现.我也尝试结束与ps aux相关的Postgres进程,但这也没有用.似乎我发现的任何过程都不正确.有没有人有什么建议可以帮助我找到并杀死托管服务器的进程?

解决方案

lsof -nP -i | grep "TCP.*:8080.*LISTEN"

使用lsof查找在端口8080上等待连接("LISTEN")的进程.使用该输出中的PID列终止该进程.

I am currently running macOS High Sierra version 10.13.6.

This is what I get when I load localhost:8080 in my browser: Apache / PHP server screenshot

I do not know how this server was started on this port because I have never used these technologies. I do mess around with web development every now and then, but I do not know what I was doing when the server started. I have looked into how to kill the process and so far the closest I have come to ending the server is killing my chrome browser. Some of the things I have tried to find the process running on port 8080:

ps aux | grep 8080
lsof -t -i @localhost:8080
netstat -l -p | grep 8080
lsof -nP -i | grep 8080

There were a few more ones that looked similar that I tried, but I cannot recall all of them. When using the lsof commands, I would usually have to put sudo in front of them for anything to show up. I would sometimes get nothing to come back and sometimes I would get something like this: Terminal output from lsof and ps aux output where the Postgres processes are.

When I got processes back that had a PID associated with them, I would try to kill them with kill -9 <PID>. Normally I would have to force this with sudo because it gave me a permission denied error (probably not the best practice). When I did this, nothing appeared to happen except other processes appeared when I searched after I killed the initial ones. I also tried to end the processes associated with Postgres from ps aux, but that did not work either. It just seems like whatever processes I am finding are not the correct ones. Does anyone have any suggestions to help me find and kill the process that is hosting the server?

解决方案

lsof -nP -i | grep "TCP.*:8080.*LISTEN"

Use lsof to find the process that is waiting for connections ("LISTEN"ing) on port 8080. Use the PID column from that output to kill the process.

这篇关于如何杀死运行在本地主机端口8080上的Apache/PHP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆