Home > Backend Development > PHP7 > Let's take a look at how to upgrade PHP5 to PHP7 under Centos.

Let's take a look at how to upgrade PHP5 to PHP7 under Centos.

coldplay.xixi
Release: 2023-02-17 21:42:01
forward
2098 people have browsed it

Let's take a look at how to upgrade PHP5 to PHP7 under Centos.

  1. First download the PHP7 installation package, use wget http://am1.php.net/distributions/php-7.2.0.tar.bz2, or visit the download directly, Then ftp to the linux server
  2. to decompress the compressed package, tar –xjf php-7.0.2.tar.bz2
  3. Enter the folder, cd php-7.0.2, and install the necessary dependency tools.
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
Copy after login

Recommended (free): PHP7

The main thing here is to upgrade, it is usually installed in php5, so this step can Omit
4. Install several dependencies (must be installed, otherwise the libphp7.so file used by apache cannot be generated later)

yum -y install perl
yum –y install perl-develyum -y install httpd-develfind /usr  -name apxs 取得所用路径,后面编译时用到。
Copy after login

5. Prepare for compilation

./configure --prefix=/usr/local/php7 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath -enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --enable-pcntl --with-curl --with-fpm-user=nginx --enable-ftp --enable-session --enable-xml --with-apxs2=/usr/bin/apxs
Copy after login

**Note: The –enable-gd-native-ttf does not need to be installed. It is used for graphics processing. If necessary, it can be installed in an extended form later
–with-apxs2= Change the path behind /usr/bin/apxs to the path obtained in step 4
–prefix=/usr/local/php7 Install it separately in the php7 folder to avoid conflict with php5**
6. Compile
make
This step is prone to many problems,
If you encounter, for example: undefine. . . .
/ext/cli./php …
Openssl
and other errors, and make sure the relevant modules are installed, generally clear the previous compilation, delete the relevant files and recompile

make clean
rm –rf /usr/local/php7
Copy after login

Generally the problem can be solved.
For other errors, please refer to this blog:
http://www.cnblogs.com/sweetXiaoma/p/5855732.html
http://www.linuxidc.com/Linux /2017-08/146220.htm
The key is to solve it yourself. Since there are too many Linux distributions and the environment configuration of each server is different, you will encounter many strange problems.
7. Install
Make install
8. Prepare the configuration file

cp php.ini-developement /etc/php.ini   //根据实际情况,可以使用production或者development默认配置cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.confcp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
Copy after login

9. Need to modify the apache configuration file
Vi /etc/httpd/conf/httpd.conf Find LoadModule php7_module modules/libphp7.so, if not added manually,
Comment out LoadModule php5_module modules/libphp5.so
cp /etc/httpd/conf.d/php.conf /etc/httpd/conf.d /php.conf_5
Vi /etc/httpd/conf.d/php.conf
Change to the following: (Comment out the ones related to php5 and change to php7 related modules)

<IfModule prefork.c>
  LoadModule php7_module modules/libphp7.so</IfModule><Files ".user.ini">
    <IfModule mod_authz_core.c>
        Require all denied    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny        Deny from all
        Satisfy All</IfModule></Files>DirectoryIndex index.php# mod_php options<IfModule  mod_php7.c>
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php</FilesMatch>
    php_value session.save_handler "files"
    php_value session.save_path    "/var/lib/php/session"
    php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"</IfModule>
Copy after login

10. Restart apache server
service httpd restart

The above is the detailed content of Let's take a look at how to upgrade PHP5 to PHP7 under Centos.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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