Search code examples
phpmacosapacheosx-elcapitan

Two versions of php in El Capitan. How do I get rid of one or upgrade the other?


In terminal,

php -v

gives

PHP 5.3.29 (cli) (built: Sep 28 2015 06:33:13)

(with imagick installed) but, in the browser (using apache)

phpinfo();

gives

PHP Version 5.5.27

(with no imagick installed) How do I resolve this?

I don't want to mess about with php.ini and httpd.conf when I'm not entirely sure what I'm doing!


Solution

  • Solved it. I entered

    locate libphp5.so
    

    into terminal to find paths to the php installations. This outputted

    /usr/libexec/apache2/libphp5.so
    /usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
    

    I then edited the apache configuration file

    sudo nano /private/etc/apache2/httpd.conf
    

    and changed

    LoadModule php5_module libexec/apache2/libphp5.so
    

    to

    LoadModule php5_module /usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
    

    NOTE : This line will be different for your local installation, copy the value outputted from the locate command above

    I then restarted apache with:

    sudo apachectl graceful
    

    Credit to this solution for the command to find the php installations