Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I run php -v from the terminal it gives me:

   PHP 5.4.12 (cli) (built: Mar 16 2013 21:46:23)

Then once setting up localhost etc and then i run a phpinfo page I get:

   PHP Version 5.3.15

How can I use the latest version of upgrade the current local one as I would like to install onto the server and ensure I have all the latest.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The first example you show that outputs this comes from the PHP command line (CLI) interface.

PHP 5.4.12 (cli) (built: Mar 16 2013 21:46:23)

The second example you show—which is coming from phpinfo() via your web server—comes from the PHP module that apache loads.

PHP Version 5.3.15

How did you install the version of PHP 5.4.12 that shows up on the command line? Also, your Apache version, is that the version installed via Mac OS X? I would run the following command to find out where the CLI version of PHP is being called from:

which php

Note that directory. The PHP 5.4 module should be in that directory somewhere.

But wiithout knowing the details, I will recommend this if you are doing web sharing via OS X. This is based on my personal Mac OS X 10.8.3 default setup.

First, open up the Apache config file:

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

Find the commented out line that reads something like this:

#LoadModule php5_module libexec/apache2/libphp5.so

Uncomment that line and set it to the path of your PHP 5.4 module:

LoadModule php5_module /my/path/to/php54/libphp5.so

Of course chaging /my/path/to/php54/ to actually match your real system path to the PHP 5.4 Apache module.

After doing that, restart Apache & then check the output of phpinfo(). It should match the command line output.

share|improve this answer
1  
Thanks for the answer, i will know more when I get back to the mac, but in mean time i updated the php using the command line, probably why that is set to 5.4.. Will get back later in the day but thanks –  Simon Davies Mar 26 '13 at 10:20
1  
Many thanks for this it seem to work once i hunted down my libphp5 file. it was at 'LoadModule php5_module /usr/local/Cellar/php54/5.4.12/libexec/apache2/libphp5.so' and the which php showed '/usr/local/bin/php' so completely different. Now i need to try and get mcrypt installed as its on the other version but this PHP info page shows it as NOT installed, any advise? thanks again –  Simon Davies Mar 26 '13 at 19:57
    
well i searched and found this to do brew install mcrypt php54-mcrypt and after a restart this seemed to have installed on my phpinfo at least many thanks again. Headache going... –  Simon Davies Mar 26 '13 at 20:04
    
Happy this all worked out! –  JakeGould Mar 26 '13 at 23:06
    
not a problem, you stopped an otherwise increasing migraine :-) –  Simon Davies Mar 27 '13 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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