[英]Apache not working after macOS Mojave update
Ok, after update macOS from High Sierra to Mojave, Apache with PHP stop working properly, so I did everything as is said in this guide - https://getgrav.org/blog/macos-mojave-apache-multiple-php-versions好的,在将 macOS 从 High Sierra 更新到 Mojave 后,使用 PHP 的 Apache 停止正常工作,所以我按照本指南中的说明做了一切 - https://getgrav.org/blog/macos-mojave-apache-multiple-php-versions
but after that, still apache not working properly, sometimes working, sometimes not, and its says in browsers ERR_CONNECTION_REFUSED or other errors like 404 or 500.但在那之后,apache 仍然无法正常工作,有时工作,有时不工作,它在浏览器中显示 ERR_CONNECTION_REFUSED 或其他错误,如 404 或 500。
In apache log is:在 apache 日志中是:
[Tue Oct 02 15:02:23.209423 2018] [mpm_prefork:notice] [pid 14579] AH00173: SIGHUP received. Attempting to restart
[Tue Oct 02 15:02:23.255957 2018] [mpm_prefork:notice] [pid 14579] AH00163: Apache/2.4.35 (Unix) PHP/7.2.10 configured -- resuming normal operations
[Tue Oct 02 15:02:23.256008 2018] [core:notice] [pid 14579] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd'
[Tue Oct 02 15:14:37.626645 2018] [mpm_prefork:notice] [pid 14579] AH00173: SIGHUP received. Attempting to restart
[Tue Oct 02 15:14:37.674603 2018] [mpm_prefork:notice] [pid 14579] AH00163: Apache/2.4.35 (Unix) PHP/7.2.10 configured -- resuming normal operations
[Tue Oct 02 15:14:37.674672 2018] [core:notice] [pid 14579] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd'
[Tue Oct 02 15:28:40.715060 2018] [mpm_prefork:notice] [pid 14579] AH00173: SIGHUP received. Attempting to restart
[Tue Oct 02 15:28:40.752117 2018] [ssl:warn] [pid 14579] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Oct 02 15:28:40.766009 2018] [mpm_prefork:notice] [pid 14579] AH00163: Apache/2.4.35 (Unix) OpenSSL/1.0.2p PHP/7.2.10 configured -- resuming normal operations
[Tue Oct 02 15:28:40.766052 2018] [core:notice] [pid 14579] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd'
I have faced similar issue with PHP 5.6 as it was running fine before Mojave upgrade.我在 PHP 5.6 上遇到了类似的问题,因为它在 Mojave 升级之前运行良好。 I did the following to resolve the issue successfully:
我做了以下操作以成功解决问题:
Run the command below sudo nano /etc/apache2/httpd.conf运行下面的命令 sudo nano /etc/apache2/httpd.conf
make sure the below modules are uncommented:确保以下模块未注释:
LoadModule authz_core_module libexec/apache2/mod_authz_core.so LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so LoadModule rewrite_module libexec/apache2/mod_rewrite.so
I have added the missing one in httpd.conf我在 httpd.conf 中添加了缺失的一个
Check the right php module for you (PHP 5.6 ot 7.x) and load the required module too by adding the line or commenting/uncommenting the lines为您检查正确的 php 模块(PHP 5.6 或 7.x)并通过添加行或注释/取消注释行来加载所需的模块
LoadModule php5_module libexec/apache2/libphp5.so LoadModule php5_module libexec/apache2/libphp5.so
OR或者
LoadModule php7_module libexec/apache2/libphp7.so
Comment the one not needed by adding "#" to start of line通过在行首添加“#”来注释不需要的
Check for any errors there检查那里是否有任何错误
For PHP 5.6: In case you were having the php 5 with brew already in system before upgarde and the above changes gives error as below "httpd: Syntax error on line 180 of /private/etc/apache2/httpd.conf: Cannot load libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): image not found"对于 PHP 5.6:如果您在升级之前已经在系统中安装了带有 brew 的 php 5,并且上述更改会给出如下错误“httpd:/private/etc/apache2/httpd.conf 第 180 行的语法错误:无法加载 libexec /apache2/libphp5.so 进入服务器:dlopen(/usr/libexec/apache2/libphp5.so, 10): image not found"
Then search for libphp5.so in the system and if found copy it to "/usr/libexec/apache2/"然后在系统中搜索libphp5.so,如果找到则将其复制到“/usr/libexec/apache2/”
In my case command was在我的情况下,命令是
sudo cp ./local/Cellar/php@5.6/5.6.25_1/libexec/apache2/libphp5.so /usr/libexec/apache2/
This all made things working in my system这一切都使我的系统能够正常工作
Further to adang's reply i also had to uncomment this line:除了 adang 的回复,我还必须取消注释这一行:
Include /private/etc/apache2/extra/httpd-userdir.conf
in order for it to know what user directories were available.以便它知道哪些用户目录可用。
Within /private/etc/apache2/extra/httpd-userdir.conf在 /private/etc/apache2/extra/httpd-userdir.conf 中
I had to uncomment this line:我不得不取消注释这一行:
Include /private/etc/apache2/users/*.conf
then:然后:
sudo apachectl restart
I had the same issue after installing the Mac OS Mojave.安装 Mac OS Mojave 后我遇到了同样的问题。 I have done the following steps and it worked with me:
我已经完成了以下步骤并且它对我有用:
brew update
then:然后:
brew upgrade
I have edited /etc/apache2/httpd.conf by uncommenting the following line:我通过取消注释以下行来编辑 /etc/apache2/httpd.conf:
LoadModule php7_module libexec/apache2/libphp7.so
Open the terminal and restart the apache server:打开终端并重启apache服务器:
sudo apachectl restart
you might find the post on this link helpful 您可能会发现此链接上的帖子很有帮助
I followed the instructions in the above answers and still got a 403 Forbidden when trying to access my /Users/myuser/Sites/
folder.我按照上述答案中的说明进行操作,但在尝试访问我的
/Users/myuser/Sites/
文件夹时仍然收到 403 Forbidden。 To fix this I had to change the user in /etc/apache2/httpd.conf
from _www
to my own user.为了解决这个问题,我必须将
/etc/apache2/httpd.conf
的用户从_www
为我自己的用户。
To do this edit your httpd.conf file using your favorite editor /etc/apache2/httpd.conf
.为此,请使用您最喜欢的编辑器
/etc/apache2/httpd.conf
编辑您的 httpd.conf 文件。 Look for:寻找:
User _www
replace with your user:替换为您的用户:
User myuser
then restart apache:然后重启apache:
sudo apachectl restart
because the topic is the httpd.conf messed up after Mojave upgrade I got also this error during sudo apachectl configtest
因为主题是 Mojave 升级后 httpd.conf 搞砸了我在
sudo apachectl configtest
期间也遇到了这个错误
Could not reliably determine the server's fully qualified domain name, using XXX. Set the 'ServerName' directive globally to suppress this message
I found out the #ServerName localhost:80
in the httpd.conf was comented out, uncommenting resolved my issue.我发现 httpd.conf 中的
#ServerName localhost:80
被注释掉了,取消注释解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.