It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
PHP (Hypertext Preprocessor) is a server-side programming language that was created specifically for web development (websites, web applications and other projects). Its main advantage over other languages is the ability to embed PHP code directly into HTML.
In this tutorial, we will install the PHP 8.3 version. However, you can install a different version by following the given steps.
CentOS 7 reached the EOL June 30, 2024:
https://blog.centos.org/2023/04/end-dates-are-coming-for-centos-stream-8-and-centos-linux-7/
Because of this, you may encounter some repository issues. We recommend that you reinstall another OS that has not yet reached EOL.
If you are using CentOS 7 and encounter a mirror issue, please check out this guide to resolve the problem.
First, update the packages:
yum update
To add the remi RPM repository, run this command:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
To install yum-utils, run the following command:
yum install yum-utils
Then, verify that the "yum-config-manager" is available on the server:
yum-config-manager
To enable the remi RPM repository, run the following command (if you want to install a different version of PHP, enter the desired version number instead of "83", for example php80 or php81)
yum-config-manager --enable remi-php83
Then you need update the system again:
yum update
To install PHP, run the following command
yum install php
After PHP is installed, you can check it by running this command:
php -v
If everything was done correctly, the command will show general information about installed PHP version:
To install PHP extension, you should run this command (change the "extension_name" to the actual extension you want to install")
yum install php-extension_name
For example:
yum install php-opcache
If you want to install multiple extensions at the same time, simply list all the required extensions after the "yum install" command:
yum install php-fpm php-curl php-cli php-json php-mysql php-opcache php-dom
To list all installed PHP extensions, run the following command:
php -m