Articles on: Dedicated Servers

How to install PHP on CentOS 8

How to install PHP on CentOS 8


If you have installed your server with anything other then CentOS 8 please open a support ticket before following this guide, following this guide on any of our preinstalls or other OS choices can result in server errors that may cause irreparable errors


Requirements


Installing REMI repo

`yum install epel-release yum-utils

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm`


Accept any prompts using y


Installing PHP


You may have multiple versions of PHP installed so to check this we can run the following command:

yum module list php


The output will show a list of all available modules, including the associated stream, version, and installation profiles.


The default PHP module is set to PHP 7.2. To install a newer PHP release, enable the appropriate version:


PHP 7.3


`dnf module reset php

dnf module enable php:remi-7.3`


PHP 7.4


`dnf module reset php

dnf module enable php:remi-7.4`


You are now ready to install PHP on your CentOS server.


The following command will install PHP and some of the most common PHP modules:


dnf install php php-opcache php-gd php-curl php-mysqlnd


FPM is installed as a dependency and used as a FastCGI server. Start the FPM service and enable it to automatically start on boot:


systemctl enable --now php-fpm

Updated on: 20/11/2021

Was this article helpful?

Share your feedback

Cancel

Thank you!