I need to get PHP 5.6 running on a Mac that had to be updated to 10.13. So I reinstalled 5.6, verified its location, and added it to httpd.conf:

LoadModule php5_module libexec/apache2/libphp5.so

...and made sure the line for PHP 7 is still commented out. Restarted Apache, and Apache starts fine, throws no errors, and works, but no PHP! So as a test, I commented out the PHP 5 line and uncommented the PHP 7 line:

LoadModule php7_module libexec/apache2/libphp7.so

...restarted Apache, and again it works fine, but still no PHP! So I queried the httpd binary to make sure I'm editing the right httpd.conf and I am. Neither version of PHP will run, and yet neither causes an error in Apache when it starts. (When I say Apache runs but PHP doesn't, I mean a browser displays:

<?php phpinfo(); ?>

...without rendering it. Help? I've run out of ideas to get PHP 5.6 running.

  • Have you done the rest of the config required to have mod_php handle .php files? – womble Oct 3 '17 at 2:38
  • 1
    No, I was not aware of anything that needed to be done to a clean 10.13 install other than commenting out the libphp7.so line in httpd.conf. What did I miss? – CaymanCarver Oct 4 '17 at 12:59

Using PHP5.6 with HighSierra

Enable building of shared Apache Handler module Make sure you have the latest version of PHP56 installed along with http option enabled (either install/upgrade/reinstall as needed)

$brew upgrade php56 --with-httpd

Linking the module in Apache2 Config file Add following statement in apache2 config file /etc/apache2/httpd.conf

LoadModule php5_module /usr/local/Cellar/php56/5.6.32_8/libexec/apache2/libphp5.so

or, for newer version 5.6.36_1 and above (credits to @avidenic)

LoadModule php5_module /usr/local/Cellar/php@5.6/5.6.36_1/lib/httpd/modules/libphp5.so

Adding the PHP5 config file

Make a copy from the php7.conf

$ cd /etc/apache2/other ; sudo cp php7.conf php5.conf

In php5.conf replace php7_module with php5_module

Restart Apache Server

$ sudo /usr/sbin/apachectl restart
  • Thanks, that point about creating a php5.conf file got me, essential! – Duncanmoo Apr 10 '18 at 20:19
  • for me, libphp5.so was in /usr/local/Cellar/php@5.6/5.6.36_1/lib/httpd/modules/libphp5.so – avidenic Jul 4 '18 at 7:36

I had to reinstall xcode stuff and php56 with apache support to make it work again.

xcode-select --install
brew reinstall php56 --with-httpd

libphp5.so is not provided by the OS any more, but it's there on the file system because we just installed it. So you have to change your apache config file enabling php5, too:

LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
  • 3
    I had already reinstalled php56 and uncommented the LoadModule line in httpd.conf with the correct pathname. Apache starts fine, but php scripts do not get rendered. – CaymanCarver Oct 22 '17 at 20:19

I don't know if you know this, but High Sierra comes with it own php version, try running this code:

for i in $(brew list | grep php); do brew uninstall $i; done

this worked for me as I was having the same issue, then i notice High Sierra was trying to load it version and not running mine.

  • High Sierra comes with php 7. Not 5.6. – axelbrz May 27 '18 at 20:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.