PHP版本差异(仅限手动安装)

Pre-installed Php & Apache on OS X Yosemite of Mac Book Pro. I had manually updated the Php on my OSX with Php5.6.9.tar downloaded from official site. and then now the Terminal runs Php version is different to the Safari Browser. How to make the browser runs same(latest) version to the terminal shown?

Php Details on Safari Browser:

  • PHP Version 5.5.20
    • Configuration Path: /etc
    • Loaded Configuration File: /etc/php.ini
    • Additional .ini files: /Library/Server/Web/Config/php
    • Server Root: /usr
    • Document Root: /Users/USER_ACCOUNT/Documents/htdocs
    • Contest Document Root: /Users/USER_ACCOUNT/Documents/htdocs

Php Details on Terminal:

  • Php Version 5.6.9
    • CLI Binary: /usr/local/bin/
    • CLI man page: /usr/local/php/man/man1/
    • CGI Binary: /usr/local/bin/
    • CGI man page: /usr/local/php/man/man1/
    • Build environment: /usr/local/lib/php/build/
    • Header Files: /usr/local/include/php/
    • Helper Programs: /usr/local/bin
    • Man Pages: /usr/local/php/man/man1/
    • PEAR Environment: /usr/local/lib/php/

Check the Server API value in the browser's phpinfo() output. If it is an Apache 2.0 Handler, probably, you haven't upgraded mod_php.

Take libphp5.so from PHP 5.6, rename it to /usr/libexec/apache2/libphp56.so and change it's path in Apache's httpd.conf

LoadModule php5_module libexec/apache2/libphp56.so

Then restart Apache