How to Install Latest PHP on CentOS

PHP is a popular programming language that has been used in web development for many years. As PHP evolves, it is critical to stay up to date in order to take advantage of the latest features and advancements. If you have a CentOS server and wish to install the latest version of PHP, this tutorial will walk you through the steps.

In this article, you’ll learn how to install PHP 8.1 on CentOS and give you all the tools you’ll need to get started. Let’s get started and update your web development skills with the most recent version of PHP.

Although you don’t have to have deep understanding of how yum works, but it’s good if you know yum package manager in case you run into any problems.

If you do run into issues, do not hesitate to ask for help in the comment section.

Prerequisites

  • Install required packages
sudo yum install epel-release
sudo yum install yum-utils
  • Add Remi Repository
sudo yum-config-manager --enable remi-php73

Install Latest PHP

sudo yum install php

And that is it. You should now have the latest PHP version installed. To verify, please use the following command –

php -v
latest PHP version
latest PHP version

At the time of writing this article, PHP 8.1.16 is the latest PHP version. It will most likely differ when PHP releases new minor and major releases.

Configuring php.ini

php.ini is the configuration file to modify the important PHP settings. Using php.ini, we can control the global settings such as maximum script execution time, file upload size, etc.

In CentOS, php.ini exists at /etc/php.ini. To edit the file using nano, we can use the following command –

sudo nano /etc/php.ini

And that’s the end of it. It is also likely that you will need to install multiple PHP versions. You can install any prior versions simply by referencing the version number in the PHP package now that you have the most recent version.

sudo yum install php73

SHARE THIS POST

MassiveGRID Banner

Leave a Reply

Your email address will not be published. Required fields are marked *