如何查明 macPorts 如何窃取我的端口:80?
我安装了 MAMP(并且工作正常),然后尝试通过 macPorts 安装 mongoDB。然后 macports 开始安装一堆依赖项。之后,http://localhost 开始给出“It Works!”屏幕。重新启动以查看是否可以修复该问题后,我发现无法启动我的 MAMP 服务器。控制台这样说:
9/13/10 1:20:54 PM [0x0-0x12012].de.appsolute.MAMP[133] (48)Address already in use: make_sock: could not bind to address [::]:80
我知道 macPorts 做了一些愚蠢的事情来扰乱我。我怎样才能知道它安装了什么窃取端口:80?
这是我尝试过的一些命令:(:80 不起作用,所以我只使用了 80)
$ sudo netstat -an | grep 80
Password:
tcp46 0 0 *.80 *.* LISTEN
udp6 0 0 fe80::21e:52ff:f.123 *.*
udp6 0 0 fe80::1%lo0.123 *.*
并且:
$ lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 451 biting_duck 39u IPv4 0x0ab806b0 0t0 TCP 192.168.0.198:49515->stackoverflow.com:http (ESTABLISHED)
firefox-b 451 biting_duck 40u IPv4 0x0ab87ec8 0t0 TCP 192.168.0.198:49517->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 41u IPv4 0x0ab88aec 0t0 TCP 192.168.0.198:49516->pz-in-f95.1e100.net:http (ESTABLISHED)
firefox-b 451 biting_duck 42u IPv4 0x0ab97334 0t0 TCP 192.168.0.198:49518->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 47u IPv4 0x0ab87abc 0t0 TCP 192.168.0.198:49519->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 48u IPv4 0x0ab886e0 0t0 TCP 192.168.0.198:49520->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 50u IPv4 0x0ab89b1c 0t0 TCP 192.168.0.198:49521->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 51u IPv4 0x0ab86680 0t0 TCP 192.168.0.198:49522->peak-colo-196-216.peak.org:http (ESTABLISHED)
firefox-b 451 biting_duck 54u IPv4 0x0ab81ef8 0t0 TCP 192.168.0.198:49523->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck 55u IPv4 0x0ab82710 0t0 TCP 192.168.0.198:49524->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck 56u IPv4 0x0ab8a334 0t0 TCP 192.168.0.198:49526->64.34.80.176:http (ESTABLISHED)
firefox-b 451 biting_duck 57u IPv4 0x0ab812d4 0t0 TCP 192.168.0.198:49525->pv-in-f101.1e100.net:http (ESTABLISHED)
I had MAMP installed (and working fine) then I tried to install mongoDB through macPorts. macports then began installing a bunch of dependencies. after that, http://localhost started giving an "It Works!" screen. after rebooting to see if it might fix it, I found that I could not start my MAMP server. console said this:
9/13/10 1:20:54 PM [0x0-0x12012].de.appsolute.MAMP[133] (48)Address already in use: make_sock: could not bind to address [::]:80
I know that macPorts did something stupid to mess with me. how can I find out what it installed thats stealing port:80?
here's some command I've tried: (:80 didn't work, so I just used 80)
$ sudo netstat -an | grep 80
Password:
tcp46 0 0 *.80 *.* LISTEN
udp6 0 0 fe80::21e:52ff:f.123 *.*
udp6 0 0 fe80::1%lo0.123 *.*
and:
$ lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 451 biting_duck 39u IPv4 0x0ab806b0 0t0 TCP 192.168.0.198:49515->stackoverflow.com:http (ESTABLISHED)
firefox-b 451 biting_duck 40u IPv4 0x0ab87ec8 0t0 TCP 192.168.0.198:49517->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 41u IPv4 0x0ab88aec 0t0 TCP 192.168.0.198:49516->pz-in-f95.1e100.net:http (ESTABLISHED)
firefox-b 451 biting_duck 42u IPv4 0x0ab97334 0t0 TCP 192.168.0.198:49518->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 47u IPv4 0x0ab87abc 0t0 TCP 192.168.0.198:49519->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 48u IPv4 0x0ab886e0 0t0 TCP 192.168.0.198:49520->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 50u IPv4 0x0ab89b1c 0t0 TCP 192.168.0.198:49521->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck 51u IPv4 0x0ab86680 0t0 TCP 192.168.0.198:49522->peak-colo-196-216.peak.org:http (ESTABLISHED)
firefox-b 451 biting_duck 54u IPv4 0x0ab81ef8 0t0 TCP 192.168.0.198:49523->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck 55u IPv4 0x0ab82710 0t0 TCP 192.168.0.198:49524->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck 56u IPv4 0x0ab8a334 0t0 TCP 192.168.0.198:49526->64.34.80.176:http (ESTABLISHED)
firefox-b 451 biting_duck 57u IPv4 0x0ab812d4 0t0 TCP 192.168.0.198:49525->pv-in-f101.1e100.net:http (ESTABLISHED)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
MongoDB 端口 不会安装任何需要或使用端口 80。它的任何依赖项也不使用。此外,MacPorts 端口在启动时获取端口 80 的唯一方法是安装启动守护程序,但 MacPorts 不会自行激活任何启动守护程序(您必须手动执行此操作)。
但是,您可以通过执行以下命令找出正在侦听特定端口的程序:
例如,
将向您显示正在侦听端口 80 的程序。这应该可以缩小占用端口的范围。
The MongoDB port doesn't install anything that would require or use port 80. Nor does any of its dependencies. Furthermore, the only way a MacPorts port could grab port 80 on startup is if it installed a launch daemon, but MacPorts doesn't activate any launch daemons on its own (you have to do that manually).
However, you can find out what program is listening on a particular port by executing
For example,
will show you the program listening on port 80. That should narrow down what is grabbing the port.
确保您的 httpd.conf 文件正确。这意味着:不超过 1 个“Listen 80”。如果您多次监听 80(或任何端口),这将触发绑定错误。
我希望这对你有用:)
Make sure your httpd.conf files are correct. This means: No more then 1 'Listen 80'. If you have Listen 80 (or whatever port) more then once, this will trigger the binding error.
I hope this is useful to you :)
如果某些服务定义它将侦听端口 80,则 launchd 将在初始启动期间保留它。它可以是 apache,但也可以是其他东西。如果您没有 apache,但遇到此问题,请尝试
它应该显示代理侦听端口 80。卸载并重新启动!
If some service defines that it will listen to port 80, launchd will reserve it during the initial boot. It can be apache, but it can be something else as well. If you do not have apache, but have this problem try
It should show you agents listening to port 80. Uninstall and restart!
根据您对 launchd 错误和 /private/etc/apache2/httpd.conf 的描述,听起来与基本操作系统一起安装的 Apache 副本已打开。检查系统偏好设置 ->服务-> Web 服务,并在需要时将其关闭。如果它没有在那里打开,请尝试:
...如果那不起作用,请查看/Library/LaunchDaemons以查看是否安装了其他正在启动Apache系统副本的东西(/usr/sbin/httpd)。
From what you describe about launchd errors and /private/etc/apache2/httpd.conf, it sounds like the copy of Apache installed with the base OS got turned on. Check System Preferences -> Services -> Web Service, and turn it off if needed. If it's not turned on there, try:
...and if that doesn't work, take a look in /Library/LaunchDaemons to see if something else has been installed that's launching the system copy of Apache (/usr/sbin/httpd).
在 Max OS 10.1 Mountain Lion 上,关闭 apache 为我解决了这个问题。
On Max OS 10.1, Mountain Lion, turning off apache fixed this problem for me.
OS X 安装了内置的 apache Web 服务器,它位于 /etc/apache2.conf 中。
当 apache Web 服务器以某种方式启动时,会显示消息“It Works!”。
以下是停止/启动它的过程。
需要 sudo 作为 Web 服务器访问端口 80。
OS X had inbuilt apache webserver installed, which is located on /etc/apache2.
The message ""It Works!" is displayed when somehow the apache webserver is started.
Below are the process to stop/ start it.
sudo is needed as webserver access port 80.