[英]localhost not working on Big Sur (Apache & Homebrew)
I know there are dozens of questions about Apache not working, but nothing seems to solve it for me.我知道有几十个关于 Apache 不起作用的问题,但似乎没有什么能解决我的问题。 I'm on macOS Big Sur 11.0.1.
我在 macOS Big Sur 11.0.1 上。
I installed Apache with brew install httpd
and then brew services start httpd
.我用
brew install httpd
安装了 Apache 然后brew services start httpd
。 Everything seems to be okay, but going to http://localhost/
gives me "This site can't be reached" error.一切似乎都很好,但是转到
http://localhost/
会给我“无法访问此站点”错误。 http://127.0.0.1/
also gives that error. http://127.0.0.1/
也给出了该错误。 My /etc/hosts
configuration seems to be fine.我的
/etc/hosts
配置似乎没问题。
I don't understand what's wrong.我不明白出了什么问题。 What can I do to find out the issue?
我该怎么做才能找出问题?
I assume you have tried to follow https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions tutorial.我假设您已尝试遵循https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions教程。 If not no worries.
如果不是不用担心。 I followed this tutorial and I got the same issue.
我按照本教程进行操作,但遇到了同样的问题。
As per my understanding you have updated to BigSur from previous version and there you have used sudo
to install apache and php etc. Now it will not work due to permission issues.据我了解,您已经从以前的版本更新到 BigSur,并且您已经使用
sudo
安装了 apache 和 php 等。现在由于权限问题它无法工作。
I am able to make it run with the following steps我可以通过以下步骤使其运行
Listen 80
to Listen 127.0.0.1:80
in /usr/local/etc/httpd/httpd.conf
/usr/local/etc/httpd/httpd.conf
中将Listen 80
更改为Listen 127.0.0.1:80
sudo /usr/local/bin/httpd -k start
to start your httpdsudo /usr/local/bin/httpd -k start
启动你的 httpd Rest follow the tutorial to install multiple versions of PHP, enabling PHP in httpd.conf
file and PHP version switcher. Rest 按照教程安装多个版本的 PHP,在
httpd.conf
文件中启用 PHP 和 Z2FEC7392304A7FC932 切换器。 After switching the version you must stop and start the httpd via sudo command i mentioned above.切换版本后,您必须通过上面提到的 sudo 命令停止并启动 httpd。
So looks like things are working with this.所以看起来事情正在处理这个问题。 I hope if I'm able to set proper permissions then I no longer need the sudo.
我希望如果我能够设置适当的权限,那么我不再需要 sudo。 And if you are at the tutorial, please check the comments at the bottom
如果您在教程中,请查看底部的评论
Take care小心
I find that我发现
apachectl stop
apachectl start
is the more reliable way to ensure httpd is running successfully.是确保 httpd 成功运行的更可靠方法。 Also always
也总是
tail -f /usr/local/var/log/httpd/error_log
@Robo Robok @Robo 机器人
apachectl stop gives me: /System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service. apachectl stop 给我:/System/Library/LaunchDaemons/org.apache.httpd.plist:找不到指定的服务。 Unload failed: 113: Could not find specified service
卸载失败:113:找不到指定的服务
Solution:解决方案:
I have same issue, I upgrade from catalina to big sur, apache is well for a month, then a restart, apache isn't working.我有同样的问题,我从 catalina 升级到 big sur,apache 一个月好了,然后重新启动,apache 不工作。
I follow above,我按照上面,
Change Listen 80 to Listen 127.0.0.1:80 in /usr/local/etc/httpd/httpd.conf
This only make things worse.这只会让事情变得更糟。
I reinstall apache use brew https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions我重新安装 apache 使用 brew https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions
same problem, not works above.同样的问题,上面不起作用。
Finally, I change back Listen 10,最后,我改回 Listen 10,
and和
sudo apachectl -k restart
make it works again.让它再次工作。
Brew services list is wrong, misleading, not trust. Brew 服务列表是错误的、误导的、不信任的。
if I run如果我跑
brew services list
I got:我有:
Name Status User Plist
httpd error root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
mysql started gemini /Users/gemini/Library/LaunchAgents/homebrew.mxcl.mysql.plist
You can see httpd is error, in fact, my apache runs well, so the info here is all wrong.可以看到httpd是错误的,其实我的apache运行良好,所以这里的信息都是错误的。
!!!!!! if apache is not working !!!!!!
run following to fix:
sudo apachectl -k stop
sudo apachectl -k start
or
sudo apachectl -k restart
Check log:
tail -f /usr/local/var/log/httpd/error_log
!!!!!! if apache is not working !!!!!!
change default port to 10:
edit file:
/usr/local/etc/httpd/httpd.conf
change to Listen : 10
server root directory:
DocumentRoot "/usr/local/var/www"
$ brew update
$ brew install apache2
$ sudo apachectl start
Access the index page at http://localhost:80 or by simply visiting localhost on the browser.访问 http://localhost:80 处的索引页面,或者只需在浏览器上访问 localhost。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.