如何查明 macPorts 如何窃取我的端口:80?

发布于 2024-09-19 17:27:49 字数 2298 浏览 3 评论 0原文

我安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

赴月观长安 2024-09-26 17:27:50

MongoDB 端口 不会安装任何需要或使用端口 80。它的任何依赖项也不使用。此外,MacPorts 端口在启动时获取端口 80 的唯一方法是安装启动守护程序,但 MacPorts 不会自行激活任何启动守护程序(您必须手动执行此操作)。

但是,您可以通过执行以下命令找出正在侦听特定端口的程序:

$ lsof -i :<port>

例如,

$ lsof -i :80

将向您显示正在侦听端口 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

$ lsof -i :<port>

For example,

$ lsof -i :80

will show you the program listening on port 80. That should narrow down what is grabbing the port.

灯角 2024-09-26 17:27:50

确保您的 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 :)

薆情海 2024-09-26 17:27:50

如果某些服务定义它将侦听端口 80,则 launchd 将在初始启动期间保留它。它可以是 apache,但也可以是其他东西。如果您没有 apache,但遇到此问题,请尝试

cd ~/Library/LaunchAgents
grep -R 80 .
cd /System/Library/LaunchDaemons
grep -R 80 .

它应该显示代理侦听端口 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

cd ~/Library/LaunchAgents
grep -R 80 .
cd /System/Library/LaunchDaemons
grep -R 80 .

It should show you agents listening to port 80. Uninstall and restart!

一抹苦笑 2024-09-26 17:27:49

根据您对 launchd 错误和 /private/etc/apache2/httpd.conf 的描述,听起来与基本操作系统一起安装的 Apache 副本已打开。检查系统偏好设置 ->服务-> Web 服务,并在需要时将其关闭。如果它没有在那里打开,请尝试:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

...如果不起作用,请查看/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:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

...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).

逆流 2024-09-26 17:27:49

在 Max OS 10.1 Mountain Lion 上,关闭 apache 为我解决了这个问题。

sudo apachectl stop

On Max OS 10.1, Mountain Lion, turning off apache fixed this problem for me.

sudo apachectl stop
你的他你的她 2024-09-26 17:27:49

OS X 安装了内置的 apache Web 服务器,它位于 /etc/apache2.conf 中。
当 apache Web 服务器以某种方式启动时,会显示消息“It Works!”。
以下是停止/启动它的过程。

sudo apachectl stop
sudo apachectl start

需要 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 apachectl stop
sudo apachectl start

sudo is needed as webserver access port 80.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文