Specifying a path when compiling PHP
./configure--prefix=/opt/php/php-5.6make && make install
This allows the PHP version to be installed to a particular path, rather than being installed under /usr/local/ . Multiple versions of PHP are stored in their respective directories, depending on the program needs to launch different PHP.
/usr/local/php/php-5.6/bin/php server.php
Use soft Links
Ln-s/usr/local/php/php-5.6/bin/php/usr/local/bin/php# or Ln-s/usr/local/php/php-5.4/bin/php/usr/local/bin/phpphp- V
If you want to switch the default PHP version, just rebuild the soft link.
Writing automatic switch version scripts
to_php56.sh, switch to default PHP to version 5.6
Rm/usr/local/bin/phprm/usr/local/bin/phpizerm/usr/local/bin/php-configln-s/usr/local/php/php-5.6/bin/php/usr/ Local/bin/phpln-s/usr/local/php/php-5.6/bin/phpize/usr/local/bin/phpizeln-s/usr/local/php/php-5.6/bin/ Php-config/usr/local/bin/php-configecho "to php5.6 Done"
to_php70.sh, switch to default PHP to version 7.0
Rm/usr/local/bin/phprm/usr/local/bin/phpizerm/usr/local/bin/php-configln-s/usr/local/php/php-7.0/bin/php/usr/ Local/bin/phpln-s/usr/local/php/php-7.0/bin/phpize/usr/local/bin/phpizeln-s/usr/local/php/php-7.0/bin/ Php-config/usr/local/bin/php-configecho "to PHP 7.0 done"
Attention:
Don't forget to remove the configuration of the PHP path in the . bash_profile File!
Extended reading:
MAC Pro Compile and install PHP 5.6.21 and problem summary
Remember Mac upgrade, compile and install PHP-5.6.28 error repair process
How can I implement multiple versions of PHP coexistence and switching?