I have three installed versions of php on my Mac. When I check using phpinfo() via a web browser, the one that is being invoked is version 5.3.15. I would like to switch it to the installed instance that is version 5.4 for the apache module (not needed for the CLI).

The reason I would like to do this is because I have used MacPorts to install php_geoip, but it is for the 5.4 version.


When I use "which" I see the following:

$ which -a php

$ which -a php54

Then checking the version of each of these gives the following:

$ /opt/local/bin/php --version
PHP 5.3.19 (cli) (built: Dec 15 2012 01:08:10) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

$ /usr/bin/php --version
PHP Warning:  PHP Startup: geoip: Unable to initialize module
Module compiled with module API=20100525
PHP    compiled with module API=20090626
These options need to match
 in Unknown on line 0
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.0-komodo, Copyright (c) 2002-2012, by Derick Rethans

$ /opt/local/bin/php54 --version
PHP 5.4.10 (cli) (built: Dec 20 2012 19:30:08) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Please note that the CLI version checks are only being used to determine the version of each instance. It is actually the proper version of the apache module libphp5.so that I will ultimately need to get working.

As you can see from the above, there is an error message from the 5.3.15 instance which I believe comes from my efforts to try to load geoip.so, as follows:

; 2013-01-10 enable geoip

In other words, I used MacPorts to install php_geoip, and as a part of that it installed the dependence of php54, because the version of geoip.so in the MacPorts ports tree needs php 5.4. I tried making the running php 5.3.15 load geoip.so from the php 5.4 instance, but it does not work, as the error message shows.

Next I tried switching the instance of php to version 5.4 by changing the LoadModule statement as shown here:

# 2012-10-28: enable php
# LoadModule php5_module libexec/apache2/libphp5.so
# 2013-01-13: change to more recent version of installed php - does not work
LoadModule php5_module /opt/local/apache2/modules/libphp5.so

However, this prevents php from working at all.

So to solve my problem, I either need to get a php 5.3.15-compatible version of geoip.so, or cause my system to use the php 5.4 instance. Any guidance on either of these approaches is appreciated.

  • 2
    An important detail missing in your question is wether you are trying to change the command-line PHP client or your web server's. – Gerry Jan 14 '13 at 14:56
  • You are correct, that is an important omission, so I have edited the question. In fact, we are only trying to changed the apache module. – Jeffrey Simon Jan 15 '13 at 13:33
  • Do you get any relevant error output (on the screen or in the Apache logs)? On a sidenote, I'd recommend taking an hour or two to check out Vagrant. It makes PHP and web development so much easier as you can set up virtual machines with a OS and configuration of choice. I never looked back to the internal Apache/PHP stack after switching. – Gerry Jan 15 '13 at 13:46
  • My email notice about Gerry's comment from 15-Jan was spam filtered, and I just found it today. There are error messages similar to those shown in the original console output regarding the failure to load geoip, because of the incompatibility. Other than that, no error messages. I did look at Vagrant and it seems like a great idea. If our needs were a bit more complex, I would think it would be valuable. But might be overkill at the present. – Jeffrey Simon Jan 27 '13 at 5:36

You must log in to answer this question.

Browse other questions tagged .