Home > System Tutorial > LINUX > Centos 7 smoothly and seamlessly upgrades PHP7.1.0 to PHP 7.1.5

Centos 7 smoothly and seamlessly upgrades PHP7.1.0 to PHP 7.1.5

PHPz
Release: 2024-09-02 13:43:20
Original
1270 people have browsed it

Centos 7平滑无缝升级PHP7.1.0到PHP 7.1.5

Experimental environment: CentOS Linux release 7.3.1611 (Core)

Kernel version: Linux version 3.10.0-514.el7.x86_64

1. There are two ways to check the php version, and the display results are the same.

The first type

# /usr/local/php/bin/php -v
Copy after login

Second type

# php  -v

PHP 7.1.0 (cli) (built: Dec 17 2016 17:00:32) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies
Copy after login

2. Before upgrading, you need to find the previous configure configuration module information and make sure it is consistent before and after the upgrade. Otherwise, normal access to the website may be affected. If you do not remember the previous configure information, you can write a phpinfo probe to find it, or Use the following command;

# php -i | grep configure

Configure Command => './configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-fpm-user=www' '--with-fpm-group=www' '--with-iconv-dir' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-fpm' '--enable-mbstring' '--with-mcrypt' '--with-gd' '--enable-gd-jis-conv' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--enable-opcache' '--with-libmbfl' '--with-onig' '--enable-pdo' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-pdo-mysql' '--enable-mysqlnd-compression-support' '--with-pear' '--enable-maintainer-zts' '--enable-session' '--with-gettext'
Copy after login

After slightly modifying the above information, you can install, configure and use it.

3. Important: Back up the old version of php first to prepare for quick rollback if the upgrade fails

 # mv /usr/local/php /usr/local/php7.1.bak
 # mkdir /renwole
 # cd /renwole
 # wget http://am1.php.net/distributions/php-7.1.5.tar.gz
 # tar zxvf php-7.1.5.tar.gz
 # cd php-7.1.5
 # ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql --enable-mysqlnd-compression-support --with-pear --enable-maintainer-zts --enable-session --with-gettext
Copy after login

After PHP compilation is completed, you will see the words "Thank you for using PHP.", indicating that the compilation is complete, execute the following installation command;

# make && make install
Copy after login

This process is a bit slow, but it will not affect your normal access to the website, please be patient...

4.After php completes the upgrade installation configuration, start copying the php configuration file

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /renwole/php-7.1.5/php.ini-development /usr/local/php/etc/php.ini
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

或者沿用老版php配置文件(如果PHP版本跨度不大,建议使用老版本php.ini,否则php配置文件中的很多东西需要重新配置),\cp -rf表示覆盖无提示

# \cp -rf /usr/local/php7.1.0.bak/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf
# \cp -rf /usr/local/php7.1.0.bak/etc/php.ini /usr/local/php/etc/php.ini
# \cp -rf /usr/local/php7.1.0.bak/etc/php-fpm.d/www.conf /usr/local/php/etc/php-fpm.d/www.conf
Copy after login

5. Now restart php-fpm

# systemctl restart php-fpm.server
Copy after login

6. Check the php version again

# /usr/local/php/bin/php -v

PHP 7.1.5 (cli) (built: May 11 2017 16:18:43) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.5, Copyright (c) 1999-2017, by Zend Technologies
Copy after login

The printed PHP version information shows; it has been successfully and seamlessly upgraded from PHP 7.1.0 to PHP 7.1.5

The above is the detailed content of Centos 7 smoothly and seamlessly upgrades PHP7.1.0 to PHP 7.1.5. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template