Step 1 – Install Epel Repository on Centos 7
sudo yum update -y
sudo yum install epel-release -y
Step 2 – Install Remi Repository on Centos 7
sudo yum -y install yum-utils https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Run the system update again:
sudo yum update -y
Step 3 – Remove the PHP version Installed
Now you need to remove the PHP and PHP-FPM previous versions if you have them installed on your server. To do this, run the following command:
sudo yum remove php php-fpm -y
Then remove the rest of the package extensions with the command below:
sudo yum remove php* -y
Now disable the Remi repository for PHP with the following command:
sudo yum-config-manager –disable ‘remi-php*’
Step 4 – Enable PHP 7.4 on Centos 7
sudo yum-config-manager –enable remi-php74
Run the command below to see if the Remi repository for PHP 7.4 is enabled on your server:
sudo yum repolist
You should get the following output:
Output
remi-php74 | 3.0 kB 00:00
remi-php74/primary_db | 263 kB 00:00
repo id repo name status
base/7/x86_64 CentOS-7 – Base 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 – x86_64 13,761
extras/7/x86_64 CentOS-7 – Extras 515
remi-php74 Remi’s PHP 7.4 RPM repository for Enterprise Linux 7 – x 459
remi-safe Safe Remi’s RPM repository for Enterprise Linux 7 – x86_ 5,263
updates/7/x86_64 CentOS-7 – Updates 5,053
repolist: 35,123
Step 5 – Install PHP 7.4 on Centos 7
sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}
To install all the PHP extensions, you can use the following command:
sudo yum install php-xxx
Verify your PHP installation on Centos 7 by checking its version:
php –version
Step 6 – Configure PHP-FPM Service on Centos 7
By default on Centos 7, the PHP-FPM service is designed to be run by (Apache) user. If you are using Nginx you need to make configuration changes at (www.conf).
You can open the file with your favorite text editor, we use vi editor:
sudo vi /etc/php-fpm.d/www.conf
Find the user and group directives and change them to Nginx as shown below:
user = nginx
group = nginx
When you are done, save and close the file.
Reload the PHP-FPM service to apply the changes:
sudo systemctl restart php-fpm
Leave A Comment
You must be logged in to post a comment.