Remember to install four mined areas with multiple versions of PHP, are you stepping on it?

Source: Internet
Author: User
Tags fpm

Remember to install a multi-version of PHP Four minefields, you stepped on it

Requirements: The company needs to install a different version of PHP on the same server, and this one is already installed on the service php.7.1, now need to have two versions, and the other version is php5.6,

The original version of PHP is to use the one-click installation Tool Oneinstack to install the tool download can refer to the official website: https://oneinstack.com/install/

(The following installations are installed with Oneinstack)

One, install another version php5.6

Note that the following is the correct installation, encountered in the pit below again

1 , installation php5.6

Because the previous PHP is also installed using Oneinstack, so the startup file is PHP-FPM, we need to modify the PHP-FPM file name to prevent the installation from being overwritten.

Stop the local php7.1

#service php-fpm Stop


Change php-fpm Startup file name

#mv/ETC/INIT.D/PHP-FPM/ETC/INIT.D/PHP-FPM.BK


2 , modify Oneinstack's options.conf file .

Use the Oneinstack tool to install, each time will read options.conf this with the file, and then install, so need to modify the file's PHP path, otherwise it will prompt, has been installed

Go to options.conf file

#vim/root/oneinstack/options.conf


Change php_install_dir=/usr/local/php to

Php_install_dir=/usr/local/php56

3 , perform installation script installation

#./install.sh


And then there's a long wait

4 , modify the PHP configuration file

We need to stop just installing PHP-FPM because the Auto-start is installed by using oneinstack default

Stop php5.6

#service php-fpm Stop


Change the PHP-FPM to PHP5-FPM and turn it into a php5.6 startup file

#mv/ETC/INIT.D/PHP-FPM/ETC/INIT.D/PHP5-FPM


Restore local php7.1 startup scripts

mv/etc/init.d/php-fpm.bk/etc/init.d/php-fpm


5 , set php5.6, php7.1 boot from:

#chkconfig--add php5-fpm#chkconfig--add php-fpm


#chkconfig php5-fpm on#chkconfig php-fpm on


6 , modify sock conflict file, prevent initiating conflict

Change the php5.6 configuration file.

#vim/usr/local/php56/etc/php-fpm.conf:


Put

Listen =/dev/shm/php-cgi.sock


Modified to:

Listen =/dev/shm/php5-cgi.sock


7 , modify the environment variables of PHP

Vim/etc/profile


Go to the last line

Put

Export Path=/usr/local/php56/bin:/usr/local/php/bin: $JAVA _home/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:$ PATH


Switch

Export Path=/usr/local/php/bin:/usr/local/php/bin: $JAVA _home/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:$ PATH


Why this change, because php5.6 version, when I execute some commands, the error (the original project has been using the php7.1, you need to change, this is a big hole, the following again)

8 , restart the PHP service

Start php7.1

#service php-fpm Start


Start php5.6

#service php5-fpm Start


9 , view multi-version run condition

Such as:

Installation Complete

Second, easy to step on the mined area and solutions

mined area I. No backup php-fpm file, install directly

Process Reason:

The first installation, can put me to harm, not to oneinstack with very skilled and then directly installed, resulting in a sudden forget to put PHP-FPM backup

Results:

After installation, found that the original php-fpm file to cover, resulting in the original php7.1 reload.

Minefield II, start PHP without modifying the php-fpm.conf file

Process Reason:

Directly start the php7.1, and then start 5.6, found that can not start, engaged for a long time, only to find that the original is Php-cgi.sock file occupancy problem

Results:

Change the php56 php-fpm.conf php-cgi.sock file to Php5-cgi.sock, reboot, finish.

mined Area III, environment variable not modified

Process Reason :

Since installing php5.6 or, with the variable environment directory that will change the environment variable's file/etc/profile, the original/usr/local/php will be changed to/usr/local/php56, this change, Cause some of my command execution errors, such as composer,php and so on.

results:

the /etc/profile/usr/local/php56 changed to/usr/local/php, the implementation of PHP-V, found the version back, command execution can also.

mined Area IV, Modify Nginx Virtual host to apply PHP version

Process reason :

Oneinstack executing the./vhost.sh script to create the virtual host is, by default, calling PHP's interface is the Php-cgi.sock file, while my new project is calling php5.6.

Results:

Change the newly completed virtual host to the PHP interface called Fastcgi_pass unix:/dev/shm/php-cgi.sock; Change to Fastcgi_pass Unix:/dev/shm/php5-cgi.sock; re-load Nginx, project deployment is successful.

Iii. Summary

A multi-version issue of a service, the main consideration is compatibility, when we install multiple versions of the service on a single server, we need to be confident enough to deploy, you can install the test on the local and then deploy to the online environment, in addition, for some popular software, Need to be proficient in mastering, to avoid errors in operation.


Remember to install four mined areas with multiple versions of PHP, are you stepping on it?

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.