frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

[CentOS 7] How to install PHP on CentOS 7

MichailMichail Moderator
edited September 2 in Linux Applications

Introduction

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.

WARNING

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.

Installation guide

1. Update the system

First, update the packages:

yum update

2. Add remi RPM repository

To add the remi RPM repository, run this command:

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

3. Install the yum-utils

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

4. Enable remi RPM repository

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

5.Repeat the system update

Then you need update the system again:

yum update

6. Install the PHP

To install PHP, run the following command

yum install php

7. Check 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:

PHP extensions

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

Tagged:
Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch