Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

php - 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

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.

In apache log is:

[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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have faced similar issue with PHP 5.6 as it was running fine before Mojave upgrade. I did the following to resolve the issue successfully:

  1. Run the command below sudo nano /etc/apache2/httpd.conf

  2. make sure the below modules are uncommented:

    LoadModule authz_core_module libexec/apache2/mod_authz_core.so

    LoadModule authz_host_module libexec/apache2/mod_authz_host.so

    LoadModule userdir_module libexec/apache2/mod_userdir.so

    LoadModule include_module libexec/apache2/mod_include.so

    LoadModule rewrite_module libexec/apache2/mod_rewrite.so

I have added the missing one in httpd.conf

  1. 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

    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

  1. Run below commands for apapche restart and test a. sudo apachectl restart b. apachectl configtest

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"

Then search for libphp5.so in the system and if found copy it to "/usr/libexec/apache2/"

In my case command was

sudo cp ./local/Cellar/[email protected]/5.6.25_1/libexec/apache2/libphp5.so /usr/libexec/apache2/

This all made things working in my system


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...