Jump to content

How to change Apache PHP version (installed with homebrew) on OSX


Recommended Posts

I have installed php version 5.4 using homebrew (brew install homebrew/php/php54) and I can now use this version on the command line ok, which overrides the default installed version 5.5 which comes with OSX El-Capitan. Now I need to modify the apache config so that it too now runs 5.4 and not 5.5.38.

Now, established wisdom says that I should be modifying /private/etc/apache2/httpd.conf. So the line under question is:

169 LoadModule php5_module libexec/apache2/libphp5.so

but that libphp5.so, is rather general and doesn't look specific to either 5.4 or 5.5.

In another article I found https://www.euperia.com/development/using-different-php-versions-osx-apache-homebrew/1441

the httpd.conf file looks like this, where the appropriate line can be left uncommented according to specific php version you require for apache:
119
120 # LoadModule php5_module libexec/apache2/libphp5.so
121 # LoadModule php5_module /usr/local/Cellar/php53/5.3.29/libexec/apache2/libphp5.so
122 LoadModule php5_module /usr/local/Cellar/php54/5.4.36/libexec/apache2/libphp5.so
123 # LoadModule php5_module /usr/local/Cellar/php55/5.5.20/libexec/apache2/libphp5.so
124 # LoadModule php5_module /usr/local/Cellar/php56/5.6.4/libexec/apache2/libphp5.so
125

My installation of php54 by homebrew is located at /usr/local/Cellar/php54/5.4.45_6/ and when I run php --version I see:

$ php --version
PHP 5.4.45 (cli) (built: Oct  1 2016 22:20:59)
Copyright © 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright © 1998-2014 Zend Technologies

Under /usr/local/Cellar/php54/5.4.45_6/, I can't find any reference to libphp5.so so that I can configure an absolute path to it (so essentially, under ../5.445_6/ I can't see a libexec/.. which I'm expecting somewhere to contain a libphp5.so that can be referenced).

As a quick test, I configured it with /usr/local/Cellar/php54/5.4.45_6/libexec/apache2/libphp5.so, but since this file does exist, apache failed to start.

So my question clearly is, how do I find the correct path to the 5.4 version of PHP, so that I can configure apache to load the module correctly on start up, thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.