The method of installing PHP7.4 in Centos8 and the solution of how to upgrade PHP

In fact, the two methods of yum and source installation have their own advantages: (this article only introduces yum installation)

  • yum command installation: from the perspective of yum installation, yum is equivalent to automatic installation for you, you don't need to worry about software dependencies, in the yum installation process, it helps you to solve all the dependencies of the software for you foolishly. And now the service startup of Centos7 has been replaced by systemctl command to control. Installing through yum will help you automatically register the service, and you can start the service through systemctl start xxx.service, which is convenient and quick. But the disadvantage is that you can't interfere with the yum installation, and the installation directories are also scattered. You may have to execute the whereis or find commands to find the path where yum is installed. Sometimes the software version installed by yum is relatively low, and you have to find other yum sources or rpm packages.
  • Source code installation: Source code compilation may have to solve a lot of dependency problems during the installation process to install a software. You can't start the service through systemctl with the installed software, because there is no configuration file for your service in the /usr/lib/systemd/system/ path, you have to write one by yourself. But the advantage is that you can choose the version of the software, customize the installation directory, and install the modules. More flexible and convenient.
  • LNMP one-click installation: LNMP one-click installation package is a Linux Shell written to install LNMP (Nginx/MySQL/) for CentOS/RHEL/Fedora/Aliyun/Amazon, Debian/Ubuntu/Raspbian/Deepin/Mint Linux VPS or independent hosts. PHP), LNMPA (Nginx/MySQL/PHP/Apache), LAMP (Apache/MySQL/PHP) shell programs for production environments. No need to input commands one by one, no need to be on duty, compile and install to optimize compilation parameters, improve performance, solve unnecessary software interdependence, especially for automatic configuration optimization.

The command to uninstall things   yum -y remove ***               (*** is the specific uninstallation of the things installed before)

yum -y remove php74-php*

This method is a relatively simple method, you can install php very simply and quickly. ( Basic usage and examples of rpm command )

#添加几个源,不然会报错
#php高版本的yum源地址,有两部分,其中一部分是epel-release,另外一部分来自webtatic。如果跳过epel-release的话,安装webtatic的时候
# 安装 EPEL 存储库
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm

 The dnf command is also fine!

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm 

 

The command used to install the yum-utils package (used for the yum-config-manager command):

dnf -y install dnf-utils
 
# 输出表明当前默认安装的 PHP 版本是 PHP 7.2。要安装较新的版本 PHP 7.4,请重置 PHP 模块
dnf module reset php
# 重置PHP模块后,启用PHP 7.4模块
dnf module install php:remi-7.4

dnf update

 

 

#Use this command to view php7.4

yum search php74*

 

  Searching for downloadable PHP modules can show the current and default ones you are using 

dnf module list php

 Then install the modules you want:

 php74: Install PHP 7.4 package

php74-php: PHP scripting language website for creating dynamic web

php74-php-gd: Module graphics library for PHP applications using gd

php74-php-cli: Command line interface for PHP

php74-php-fpm: PHP FastCGI process manager

php74-php-gmp: A library of PHP application modules for using GNU

php74-php-mbstring: A module for multi-byte string processing for PHP applications

php74-php-pecl-lzf: x86_64: handle LZF de/compressed expansion

php74-php-pecl-rar: PHP extension for reading RAR archives

php74-php-pecl-zip: The extension of a ZIP file

and many more········

# 运行一下
yum install php74-php 

 Use the following command to install additional packages

yum search php74*

yum install php74-xxx
例如:
dnf install -y  php74*-gd php74*-mbstring php74*-intl php74*-pecl-apcu\
     php74*-mysqlnd php74*-opcache php74*-json php74*-zip
运行并查看版本, 重启命令, 添加自动启动,链接php文件
#运行并查看版本
php74 -v
#重启命令php-fpm
systemctl restart php74-php-fpm
#添加自动启动
systemctl enable php74-php-fpm
#查看php7.4的安装路径
whereis php
#链接php文件
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

 

Reference: https://www.cnblogs.com/alliancehacker/p/12255445.html

Guess you like

Origin blog.csdn.net/q1246192888/article/details/115013389
Recommended