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.

Apr 15, 2021 am 10:50 AM
php5 php7

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between php5 and php8 What is the difference between php5 and php8 Sep 25, 2023 pm 01:34 PM

The differences between php5 and php8 are in terms of performance, language structure, type system, error handling, asynchronous programming, standard library functions and security. Detailed introduction: 1. Performance improvement. Compared with PHP5, PHP8 has a huge improvement in performance. PHP8 introduces a JIT compiler, which can compile and optimize some high-frequency execution codes, thereby improving the running speed; 2. Improved language structure, PHP8 introduces some new language structures and functions. PHP8 supports named parameters, allowing developers to pass parameter names instead of parameter order, etc.

What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? Apr 02, 2024 pm 07:39 PM

To resolve the plugin not showing installed issue in PHP 7.0: Check the plugin configuration and enable the plugin. Restart PHP to apply configuration changes. Check the plugin file permissions to make sure they are correct. Install missing dependencies to ensure the plugin functions properly. If all other steps fail, rebuild PHP. Other possible causes include incompatible plugin versions, loading the wrong version, or PHP configuration issues.

How to install mongo extension in php7.0 How to install mongo extension in php7.0 Nov 21, 2022 am 10:25 AM

How to install the mongo extension in php7.0: 1. Create the mongodb user group and user; 2. Download the mongodb source code package and place the source code package in the "/usr/local/src/" directory; 3. Enter "src/" directory; 4. Unzip the source code package; 5. Create the mongodb file directory; 6. Copy the files to the "mongodb/" directory; 7. Create the mongodb configuration file and modify the configuration.

How to solve the problem when php7 detects that the tcp port is not working How to solve the problem when php7 detects that the tcp port is not working Mar 22, 2023 am 09:30 AM

In php5, we can use the fsockopen() function to detect the TCP port. This function can be used to open a network connection and perform some network communication. But in php7, the fsockopen() function may encounter some problems, such as being unable to open the port, unable to connect to the server, etc. In order to solve this problem, we can use the socket_create() function and socket_connect() function to detect the TCP port.

How to change port 80 in php5 How to change port 80 in php5 Jul 24, 2023 pm 04:57 PM

How to change port 80 in php5: 1. Edit the port number in the Apache server configuration file; 2. Edit the PHP configuration file to ensure that PHP works on the new port; 3. Restart the Apache server, and the PHP application will start running on the new port. run on the port.

PHP Server Environment FAQ Guide: Quickly Solve Common Problems PHP Server Environment FAQ Guide: Quickly Solve Common Problems Apr 09, 2024 pm 01:33 PM

Common solutions for PHP server environments include ensuring that the correct PHP version is installed and that relevant files have been copied to the module directory. Disable SELinux temporarily or permanently. Check and configure PHP.ini to ensure that necessary extensions have been added and set up correctly. Start or restart the PHP-FPM service. Check the DNS settings for resolution issues.

How to install and deploy php7.0 How to install and deploy php7.0 Nov 30, 2022 am 09:56 AM

How to install and deploy php7.0: 1. Go to the PHP official website to download the installation version corresponding to the local system; 2. Extract the downloaded zip file to the specified directory; 3. Open the command line window and go to the "E:\php7" directory Just run the "php -v" command.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles