Install PHP 7.4 on CentOS 7

This tutorial provides a step-by-step guide to adding EPEL and REMI repositories and installing PHP 7.4 on CentOS 7. It includes commands for installing PHP and additional packages, and verifying the PHP installation.

1. Step 1: Add EPEL and REMI Repository

1
2
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

2. Step 2: Install PHP 7.4 on CentOS 7

  • Enable PHP 7.4 Remi repository
1
2
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php74
  • Install
1
2
sudo yum update
sudo yum install php php-cli
  • Install additional packages:
1
sudo yum install php-xxx

Example:

1
sudo yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
  • Check Version
1
2
3
4
$ php -v
PHP 7.4.0 (cli) (built: Nov 26 2019 20:13:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

View enabled modules

1
$ php --modules
使用 Hugo 构建
主题 StackJimmy 设计