PHP not working after MacOS update to High Sierra

apachelinuxmacosPHP

I updated my mac to newest version of os. When I try to run PHP project, browser shows the php code instead of interpreting it. I noticed that in new OS php is in version 7.1. I installed 5.6 (it's required for me) using homebrew and change module in httpd.conf to:

LoadModule php5_module
/usr/local/Cellar/php56/5.6.31_7/libexec/apache2/libphp5.so

Here's apache error log:

[Tue Sep 26 23:59:38.600410 2017] [mpm_prefork:notice] [pid 980]
AH00169: caught SIGTERM, shutting down [Tue Sep 26 23:59:38.622998
2017] [core:notice] [pid 980] AH00060: seg fault or similar nasty
error detected in the parent process AH00557: httpd:
apr_sockaddr_info_get() failed for MacBook-Pro-Kamil.local AH00558:
httpd: Could not reliably determine the server's fully qualified
domain name, using 127.0.0.1. Set the 'ServerName' directive globally
to suppress this message [Tue Sep 26 23:59:48.838005 2017]
[mpm_prefork:notice] [pid 991] AH00163: Apache/2.4.27 (Unix)
PHP/5.6.31 configured — resuming normal operations [Tue Sep 26
23:59:48.838097 2017] [core:notice] [pid 991] AH00094: Command line:
'/usr/sbin/httpd -D FOREGROUND'

Best Answer

Adding the following lines to my httpd.conf file fixed the problem:

AddType x-httpd-php .php
AddHandler application/x-httpd-php .php .php5

Hopefully this helps!

Edit: just to provide a bit more detail, as crmpicco suggests, I did also replace the new High Sierra httpd.conf and httpd-vhosts.conf files with my old Sierra ones like so:

mv httpd-vhosts.conf~previous httpd-vhosts.conf
mv httpd.conf~previous httpd.conf

Even after all of this and restarting Apache it still wasn't working - had to do a reboot for everything to take effect.

Related Topic