Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the coexistence of multiple versions of php in Linux system (ultra-simple)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Since the advent of php7, as the latest version control, I immediately upgrade the experience, but because there are still old programs running on the server, I have to deploy a php multi-version coexistence environment.

The existing environment is lnmp

-CentOS 6.7

-nginx 1.10.1

-mariadb-10.0.26

-php 7.0.8

For better compatibility with older php programs, 5.4.45 is recommended. It is mainly compatible with mysql extensions.

Start installation

The first step is to download the php-5.4.45.tar.gz source package.

Install through source code

# tar xzvf php-5.4.45.tar.gz# cd php-5.4.45#. / configure-prefix=/usr/local/php54-- with-config-file-path=/usr/local/php54/etc-- enable-fpm-- with-fpm-user=www-- with-fpm-group=www-- with-mysql=mysqlnd-- with-mysqli=mysqlnd-- with-pdo-mysql=mysqlnd-- with-iconv-dir-- with-freetype-dir=/usr/local/freetype-- with-jpeg-dir-- with -png-dir-- with-zlib-- with-libxml-dir=/usr-- enable-xml-- disable-rpath-- enable-bcmath-- enable-sysvsem-- enable-inline-optimization-- with-curl-- enable-mbregex-- enable-mbstring-- with-mcrypt-- enable-ftp-- with-gd-- enable-gd-native-ttf-- with-openssl-with-mhash-- enable-pcntl-- enable-sockets-- with-xmlrpc-- enable-zip- -enable-soap-- with-gettext-- disable-fileinfo-- enable-intl-- with-xsl# make ZEND_EXTRA_LIBS='-liconv'# make install# cp php.ini-production / usr/local/php/etc/php.ini

Php.ini configuration

Post_max_size = 50Mupload_max_filesize = 50Mdate.timezone = PRCshort_open_tag = Oncgi.fix_pathinfo=0max_execution_time = 300 execru, the exectrum, the system, the chrootdepartment, the scandir, the chgrp, the chgrp, the shell.exectemology, the openshop, the procession, the status, the popper, the altered, the inistry, the restorem, the dl, the openlog, the syslog, the readlinklink, the symlink, the symlink, the popepthru, the streamcards, socketserver.

Php-fpm.conf configuration

# vim / usr/local/php/etc/php- fpm.confu [global] pid = / usr/local/php54/var/run/php-fpm.piderror_log = / usr/local/php54/var/log/php-fpm.loglog_level = Notice [www] listen = / tmp/php54-cgi.socklisten.backlog =-1listen.allowed_clients = 127.0.0.1:9001listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = dynamicpm.max_children = 40pm.start_servers = 20pm.min_spare_servers = 20pm.max_spare_servers = 40request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = var/log/slow.log

Note: the key point is to configure listening ports and processes

Start php-fpm

# cp sapi/fpm/init.d.php-fpm / etc/init.d/php54-fpm# chmod + x / etc/init.d/php54-fpm# / etc/init.d/php54-fpm start

Modify the nginx configuration to use php-5.4.45 for the required service configuration

Location ~ [^ /]\ .php (/ | $) {try_files $uri = 404; fastcgi_pass unix:/tmp/php54-cgi.sock; fastcgi_index index.php; include fastcgi.conf;}

Configure php54-fpm boot for php-5.4.45 to start automatically

# chkconfig-add php54-fpm# chkconfig php54-fpm on

Chkconfig function description: check and set up various services of the system.

Syntax: chkconfig [- add] [- del] [- list] [system Services]

Chkconfig [- level] [system Services] [on/off/reset]

The focus of this program is

Each version of PHP should be installed in a new separate folder

Each PHP version of the php-fpm.conf configuration file needs to set a different process name and listening port

The PHP version listening port or process name to be used is specified in the nginx configuration file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report