简体   繁体   English

无法在本地连接到 apache 服务器

[英]Cannot connect to apache server locally

I am trying to access an Apache server on my local machine, but can't get it to work.我正在尝试访问本地计算机上的 Apache 服务器,但无法使其正常工作。 I had it working last week, but then it randomly stopped working.我上周让它工作了,但后来它随机停止工作。 I have edited the httpd.conf file to update the port to 9876. I also added the ExecCGI directive in the HTDocs directory.我编辑了 httpd.conf 文件以将端口更新为 9876。我还在 HTDocs 目录中添加了 ExecCGI 指令。

I usually see the index.html page I created by visiting localhost:9876, but now I just see an erroneous page.我通常看到我通过访问localhost:9876创建的index.html页面,但现在我只是看到一个错误的页面。 When I just run localhost:80, I see the it works page!当我运行 localhost:80 时,我看到了它的工作页面! How is something still showing up on port 80 when I clearly changed it to another port?当我清楚地将其更改为另一个端口时,端口 80 上如何仍然显示某些内容? I read more about this and found out it has to do with the sharing settings on OSX.我阅读了更多相关内容,发现它与 OSX 上的共享设置有关。 These settings were never enabled to begin with.这些设置从一开始就没有启用。 Why am I still seeing a page on port 80, and why is the designated port I chose not showing any content?为什么我在80端口还是看到页面,为什么我选择的指定端口没有显示任何内容?

Things I have done:我做过的事情:

  1. I have tried stopping and restarting the server multiple times(with sudo)我曾多次尝试停止和重新启动服务器(使用 sudo)
  2. I use the web browser or netcat to connect to apache, but I get no response.我使用网络浏览器或 netcat 连接到 apache,但没有任何响应。

I ran lsof -i4TCP:9876 and get the following output:我运行 lsof -i4TCP:9876 并得到以下输出:

launchd      1           root   25u  IPv6 0xee69429dde6f1b6f      0t0    TCP localhost:ipp (LISTEN)
launchd      1           root   26u  IPv4 0xee69429dde6f2b77      0t0    TCP localhost:ipp (LISTEN)
LogMeIn     82           root    5u  IPv4 0xee69429dde6f238f      0t0    TCP *:globe (LISTEN)
vpnagentd   83           root    6u  IPv4 0xee69429de115bb77      0t0    TCP localhost:29754 (LISTEN)
GitHub     201  kamranpirwani    6u  IPv4 0xee69429de35f4b77      0t0    TCP localhost:25035 (LISTEN)
GitHub     201  kamranpirwani    7u  IPv6 0xee69429dde6f0eaf      0t0    TCP localhost:25035 (LISTEN)
mysqld     412         _mysql   14u  IPv6 0xee69429dde6efdaf      0t0    TCP *:mysql (LISTEN)
Coda\x202  726  kamranpirwani    5u  IPv4 0xee69429deb25fb77      0t0    TCP *:6942 (LISTEN)
Coda\x202  726  kamranpirwani    7u  IPv6 0xee69429dde6f12ef      0t0    TCP *:6942 (LISTEN)
Coda\x202  726  kamranpirwani   10u  IPv4 0xee69429deb47438f      0t0    TCP *:50490 (LISTEN)
Coda\x202  726  kamranpirwani   11u  IPv6 0xee69429dde6f062f      0t0    TCP *:50490 (LISTEN)
Coda\x202  726  kamranpirwani   12u  IPv4 0xee69429dea898b77      0t0    TCP *:50491 (LISTEN)
Coda\x202  726  kamranpirwani   13u  IPv6 0xee69429dde6ef96f      0t0    TCP *:50491 (LISTEN)
httpd     1879           root    5u  IPv6 0xee69429dde6f172f      0t0    TCP *:http (LISTEN)
httpd     1880           _www    5u  IPv6 0xee69429dde6f172f      0t0    TCP *:http (LISTEN)
httpd     1920           _www    5u  IPv6 0xee69429dde6f172f      0t0    TCP *:http (LISTEN)

This leads me to believe the my apache web server is listening for requests on this port.这让我相信我的 apache Web 服务器正在侦听此端口上的请求。 Why can't the browser or netcat connect to it?为什么浏览器或netcat连接不上?

Edit:编辑:

Log file(with personal email removed) http://pastebin.com/84RcB2Er日志文件(删除个人邮箱) http://pastebin.com/84RcB2Er

First you say (emphasis mine):首先你说(强调我的):

I am trying to access an Apache server on my local machine , but can't get it to work.我正在尝试访问本地计算机上的 Apache 服务器,但无法使其正常工作。

But then you say (again, emphasis mine):但是然后你说(再次强调我的):

When I just run on localhost , I see the it works page!当我在localhost 上运行时,我看到了它的工作页面!

So unclear what the problem is.When you say you edited the .conf which one?所以不清楚问题是什么。当你说你编辑了.conf哪一个? Apache by default can handle virtual hosts so it's possible you are running two virtual hosts on your machine with different document roots: One responding on port 80 & the other on port 9876 .默认情况下,Apache 可以处理虚拟主机,因此您可能在机器上运行两个具有不同文档根目录的虚拟主机:一个在端口80上响应,另一个在端口98769876 Can you exact details of the contents of the file you changed?你能详细说明你更改的文件的内容吗?

EDIT: The original poster indicates they are editing the httpd.conf in this location:编辑:原始海报表明他们正在此位置编辑httpd.conf

~/apache/conf/httpd.conf

When the systemwide Apache config is in this location:当系统范围的 Apache 配置位于此位置时:

/etc/apache2/httpd.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM