-1
在我的Mac(10.11.5),我發現一個奇怪的PHP服務器監聽我的本地主機:如何找到在OSX上偵聽本地主機的進程?
$ curl -i localhost
HTTP/1.1 200 OK
Date: Mon, 11 Jul 2016 10:05:11 GMT
Server: Apache/2.4.18 (Unix) PHP/5.6.23
Content-Location: index.html.en
Vary: negotiate
TCN: choice
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
但我找不到任何PHP程序:
$ ps -ef | grep php
501 724 500 0 6:06PM ttys000 0:00.00 grep php
而且任何可疑過程偵聽端口80:
$ lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 526 Sona 202u IPv4 0x9de3b88faf523ff9 0t0 TCP sayakiss-mbp.lan:49823->72-165-119-59.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 219u IPv4 0x9de3b88faf521c19 0t0 TCP sayakiss-mbp.lan:49827->72-165-119-17.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 226u IPv4 0x9de3b88faf510e09 0t0 TCP sayakiss-mbp.lan:49808->pixel.quantserve.com:http (CLOSED)
Google 526 Sona 236u IPv4 0x9de3b88faf523701 0t0 TCP sayakiss-mbp.lan:49824->72-165-119-59.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 237u IPv4 0x9de3b88faf522e09 0t0 TCP sayakiss-mbp.lan:49825->72-165-119-59.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 238u IPv4 0x9de3b88faf522511 0t0 TCP sayakiss-mbp.lan:49826->72-165-119-59.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 239u IPv4 0x9de3b88faf53ee09 0t0 TCP sayakiss-mbp.lan:49828->72-165-119-17.dia.static.qwest.net:http (CLOSED)
Google 526 Sona 240u IPv4 0x9de3b88faf53f701 0t0 TCP sayakiss-mbp.lan:49829->72-165-119-17.dia.static.qwest.net:http (CLOSED)
QQ 640 Sona 11u IPv4 0x9de3b88f96e3fff9 0t0 TCP sayakiss-mbp.lan:49717->123.151.10.189:http (ESTABLISHED)
QQ 640 Sona 13u IPv4 0x9de3b88f96e3fff9 0t0 TCP sayakiss-mbp.lan:49717->123.151.10.189:http (ESTABLISHED)
我的問題:
- 如何找到偵聽localhost的進程? ?
- 如何找到它通過PHP返回文件(正如你看到的,PHP返回的內容,包含
It works!
,所以必須有一個文件包含文本...)
編輯:
後加入須藤用lsof
,並讓更多:
$ sudo lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 75 root 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 242 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 456 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 458 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 459 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 460 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 461 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 462 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
httpd 463 _www 4u IPv6 0x9de3b88f918c1379 0t0 TCP *:http (LISTEN)
...
的ramain是一樣的沒有sudo的。
但我的朋友不具有的OSX預安裝的Apache Web服務器......你能不能請您給有關的內容? – Sayakiss
也許他們禁用了它......?你可以像這樣禁用它: 'sudo launchctl unload -w/System/Library/LaunchDaemons/org.apache.httpd.plist' – Stuart
如果我禁用它,會發生什麼情況?我認爲OS X因爲某些特定的原因而部署了HTTP服務器...... – Sayakiss