Install PHP 7.4 on CentOS 8 RHEL 8. This guide let you learn how install the latest PHP version 7.4 on your CentOS system or your CentOS server on any VPS or any Cloud or any Dedicated hosting and configure it with Apache and Nginx.
The latest PHP 7.4 version is released on November 28th, 2019. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.
This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. This set up will work on all Linux servers.
- A CentOS server set up
- Completed the initial CentOS server setup. You can choose CentOS 8 for boot image
If you are using Google Cloud Platform to install PHP you need the following steps to be done.
- A running Compute Engine, see the Setting up Compute Engine Instance with CentOS.
Here are some cloud hosting providers you can choose from with very low cost and free trial.
Make sure your CentOS server is having the latest packages by running the following command.
sudo yum update sudo yum upgrade
This will update the package index and update the installed packages to the latest version.
Add EPEL and REMI repositories
Add the EPEL and REMI repositories which has PHP 7.4 package and other required PHP extensions.
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Once you have added these repositories you can install PHP 7.4.
Install PHP 7.4
Execute the following command to install
dnf. Then you can install PHP.
sudo dnf -y install dnf-utils
php:remi-7.4 module to install PHP 7.4.
sudo dnf module install php:remi-7.4
After the installation has completed, you can confirm the installation using the following command
Install PHP 7.4 Extensions
Installing PHP extensions are simple with the following syntax.
sudo yum install php-extension_name
Now you can install some commonly used
php-extensions for WordPress with the following command.
sudo yum install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-json php-libxml php-pecl-imagick php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlib
Configure PHP 7.4
Now we configure PHP for Web Applications by changing some values in
For PHP 7.4 with Apache the
php.ini location will be in following directory.
sudo nano /etc/php.ini
F6 for search inside the editor and update the following values for better performance.
upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000
Once you have modified your PHP settings you need to restart your Apache for the changes to take effect.
Configure PHP 7.4 FPM Pools
PHP 7.4 FPM allows you to configure the
group that the service will run under. You can modify these with these commands
sudo nano /etc/php-fpm.d/www.conf
Change the following lines by replacing the www-data with your
user = username group = username listen.owner = username listen.group = username
Y to save the configuration and check if the configuration is correct and restart PHP.
Restart PHP 7.4 FPM
Once you have updated your PHP FPM settings you need to restart it to apply the changes.
sudo php-fpm7.4 -t sudo service php7.4-fpm restart
Now you are having PHP 7.4 Installed and configured.
Now you have learned how to install PHP 7.4 on your CentOS server.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.