简体   繁体   English

本地主机不适用于 Big Sur (Apache & Homebrew)

[英]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我可以通过以下步骤使其运行

  1. Change 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
  2. use sudo /usr/local/bin/httpd -k start to start your httpd使用sudo /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:解决方案:

  1. sudo apachectl start first start the server sudo apachectl start 首先启动服务器
  2. sudo apachectl stop then you can stop it sudo apachectl stop 然后你可以停止它

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.

相关问题 Macbook Pro 2020 M1 - MacOS Big Sur - Homebrew 不工作 - Macbook Pro 2020 M1 - MacOS Big Sur - Homebrew not working 在 Big Sur 上安装自制 ruby​​ 时出现“ld: library not found for -lSystem” - "ld: library not found for -lSystem" when installing homebrew ruby on Big Sur 在 macOS Big Sur 上使用 Homebrew 错误升级到 PHP 8 - upgrade to PHP 8 using Homebrew Error on macOS Big Sur Mac OS Big Sur - Homebrew Apache - 48) 地址已经在使用:AH00072:make_sock:无法绑定到地址 0.0.0.0:8080 - Mac OS Big Sur - Homebrew Apache - 48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8080 在 Mac OS 10.16 (Big Sur) 中通过 homebrew 构建 libzip 时找不到 libz.dylib - Can not find libz.dylib when build libzip by homebrew in Mac OS 10.16 (Big Sur) "无法在 Big Sur 上使用 Apache 对 PHP v7.4 进行代码设计" - Unable to codesign PHP v7.4 with Apache on Big Sur 使用自制软件在 Mac Big Sur 上为 PHP 7.3.24 安装 pgsql 扩展时出现问题 - Issues installing pgsql extension for PHP 7.3.24 on Mac Big Sur using homebrew 找不到在 MacOS Big Sur 上安装 Apache NetBeans IDE 的 JDK - No JDK found installing Apache NetBeans IDE on MacOS Big Sur "无法让 csshX 在 Mac OS Big Sur 上运行" - Can't make csshX working on Mac OS Big Sur 在不受支持的 Mac 上,Spotlight 搜索在 MacOS Big Sur 中不起作用 - Spotlight search is not working in MacOS Big Sur on unsupported macs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM