How can I implement multiple versions of PHP coexistence and switching?

Source: Internet
Author: User
Tags php server

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.