如何调试Localhost-无法访问此网站

时间:2018-10-29 17:06:12

标签: linux macos apache lamp

我使用https://getgrav.org/blog/macos-mojave-apache-upgrade-homebrew教程系列在MacOS计算机上设置了LAMP。

它可以工作一两个月,然后突然(不对配置进行任何更改)它将停止工作。

This site can’t be reached
localhost refused to connect.
ERR_CONNECTION_REFUSED

上一次发生这种情况时,我放弃了,从头开始重新安装。我不想每次停止工作都必须这样做。

这是我到目前为止所尝试的:

jackrobson$ ps -aef | grep httpd
  501 84635   459   0  5:03pm ttys000    0:00.00 grep httpd
jackrobson$ sudo apachectl -k restart
jackrobson$ tail -f /usr/local/var/log/httpd/error_log
[Sun Sep 16 14:43:22.548017 2018] [mpm_prefork:notice] [pid 74] AH00173: SIGHUP received.  Attempting to restart
[Sun Sep 16 14:43:22.635379 2018] [mpm_prefork:notice] [pid 74] AH00163: Apache/2.4.34 (Unix) PHP/7.0.31 configured -- resuming normal operations
[Sun Sep 16 14:43:22.635437 2018] [core:notice] [pid 74] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'

我的/usr/local/etc/httpd/extra/httpd-vhosts.conf如下:

<VirtualHost *:80>
    DocumentRoot "/Users/jackrobson/Projects"
    ServerName localhost
</VirtualHost>

如您所见,最后一个错误发生在两个星期前。即使我遇到ERR_CONNECTION_REFUSED错误,今天也没有错误。

任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

让它工作,这些是我在工作之前所做的命令:

jackrobson$ sudo apachectl stop
jackrobson$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
jackrobson$ brew services restart httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)