OneinStackPHP multi-version coexistence tutorial

Source: Internet
Author: User
The OneinStackPHP multi-version coexistence tutorial is based on the lnmp mode in the one-click PHP/JAVA installation tool of OneinStack. users want one website to run in php5.4 and the other website to run in php7, multiple PHP versions are supported on one server. The steps are as follows:

1. install OneinStack

Select lnmp mode, php5.4 installed by default, installation steps refer to: http://oneinstack.com/install/

The options are as follows:

  1. Install Nginx

  2. Do not install Apache

  3. Do not install Tomcat

  4. Install MySQL-5.6

  5. Install php-5.4

  6. ....

2. install php7
  1. Service php-fpm stop # install php later and stop php

  2. Mv/etc/init. d/php-fpm {, _ bk} # install php later to overwrite and back up the startup script

The default php5.4 installation path is/usr/local/php. if you install php again, the system prompts that php has been installed. Therefore, you must modify options. in the php installation directory of conf, set the php7 installation path to/usr/local/php7 and modify/root/oneinstack/options. conf:

  1. Php_install_dir =/usr/local/php7

Run again./install. sh, select Install php-7, and select n for others, Waiting for ing

3. modify the php configuration file
  1. Service php-fpm stop # stop the php7 startup script

  2. Mv/etc/init. d/php-fpm/etc/init. d/php7-fpm # Rename php7 startup script

  3. Mv/etc/init. d/php-fpm_bk/etc/init. d/php-fpm # restore php5.4 startup script

Set php5.4 and php7 to start automatically:

  1. # CentOS:

  2. Chkconfig -- add php7-fpm

  3. Chkconfig -- add php-fpm

  4. Chkconfig php7-fpm on

  5. Chkconfig php-fpm on


  6. # Ubuntu/Debian:

  7. Update-rc.d php7-fpm ULTS

  8. Update-rc.d php-fpm defaults

To prevent sock conflicts in php5.4 and php7 listening, modify the listen of php7 and change the configuration file/usr/local/php7/etc/php-fpm.conf:

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

  2. # Change

  3. Listen =/dev/shm/php7-cgi.sock

Start php5.4 and php7 manually:

  1. Service php-fpm start # start php5.4

  2. Service php7-fpm start # start php7

For example:

4. modify the nginx virtual host configuration file

. /Vhost. sh: bind the domain name. The default value is php5.4. to run the website in php7, modify/usr/local/nginx/conf/vhost/www.oneinstack.com. conf (www.oneinstack.com changed to bind your own domain name ):

  1. Fastcgi_pass unix:/dev/shm/php-cgi.sock;

  2. # Change

  3. Fastcgi_pass unix:/dev/shm/php7-cgi.sock;

Reload nginx to make the configuration take effect:

  1. Service nginx reload

Reprinted:

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.