如果要安装PHP7,首先需要在Centos7系统上安装并启用EPEL和Remi存储库
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-utils 可以扩展yum的默认功能,用于管理yum存储库以及程序包,而无需进行任何手动配置,yum-utils提供的程序之一是yum-config-manager,可以使用它来启用Remi存储库作为默认存储库,以安装不同的PHP版本。
yum install yum-utils
yum-config-manager --enable remi-php71 yum-config-manager --enable remi-php72 yum-config-manager --enable remi-php73 yum-config-manager --enable remi-php74
yum-config-manager --enable remi-php74
yum -y install php php-cli php-common php-gd php-json php-ldap php-mbstring php-mysqlnd php-pdo php-xml php-devel php-embedded php-mcrytp php-pecl-mongodb php-pecl-redis php-pecl-memcached php-opcache php-fpm
[root@centos7]# php -v PHP 7.4.26 (cli) (built: Nov 16 2021 15:31:30) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies
systemctl start php-fpm
systemctl stop php-fpm
systemctl status php-fpm
[root@centos7]# php -m [PHP Modules] bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv igbinary json ldap libxml mbstring memcached mongodb msgpack mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline redis Reflection session SimpleXML sockets sodium SPL sqlite3 standard tokenizer xml xmlreader xmlwriter xsl Zend OPcache zlib [Zend Modules] Zend OPcache