Перейти к основному контенту

Обновление версии PHP с 7.4 до 8.1

How to instructions for installing PHP 8.1 on CentOS 7

Introduce

What is PHP?

PHP: Hypertext Preprocessor, commonly abbreviated to PHP, is a scripting language or type of code preeminent used to develop general-purpose, open-source, server-written applications. It is very suitable for the web and can be easily embedded into HTML pages. Because it is optimized for web applications, is fast, compact, has a syntax similar to C and Java, is easy to learn, and has a relatively shorter product build time compared to other languages, PHP has quickly become one of the most popular languages in the world. The world’s most popular web programming language.

PHP 8.1 is currently under development and will be released on November 25, 2021. With PHP 8.1 it will be the most powerful content management on major and popular platforms like Joomla, Drupal, WordPress, OpenCart, Magento, and OctoberCMS, in addition, PHP 8.1 comes with a host of new features and improvements. Right now, I will introduce some new outstanding features and show you how to install PHP 8.1 on CentOS 7 to start exploring its cool features more closely.

What’s New in PHP 8.1?

  • Enums have been integrated
  • Readonly properties (Class properties can be marked as read-only and thus can only be written once.
  • Never keyword (A new return type hint named Never was added in PHP 8.1)
  • DNS over HTTPS (DoH) support.
  • Support AVIF Image format.
  • Added support for Fibers (Low-level mechanism for parallel management).
  • The PHP Curl extension now supports HTTP(S) requests with File upload.
  • Support for new fdatasync() and fsync() functions. 
  • PHP 8.1 adds array_is_list as a built-in function .
  • Speed ​​efficiency improved  from 5% to 8% compared to the old version
  • Unpack the array using string keys.


Install PHP 8.1 on CentOS 7

Since the default YUM repository in CentOS 7 does not have PHP 8.1 packages available, we will use the REMI repository to install 8.1 on CentOS 7

Step 1: SSH into the server

To install PHP 8.1 on CentOS 7, the first thing we need to do is SSH or access your VPS or server with root privileges first.

After successfully SSH, we continue with step 2.

Step 2: Install PHP 8.1 on CentOS 7

To get started, you need to add the Remi repository first so that from there you will be able to install PHP 8.1 on CentOS7.

To install and activate the Remi repository on CentOS 7, you need to run the following commands:

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Below is the output after running the above commands.

Instructions for installing PHP 8.1 on CentOS7
  • To install the PHP 8.1 packages and activate them permanently, you need to run the following commands:
yum -y install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php81
yum repolist
yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}

Below is the output after running the above commands

Instructions for installing PHP 8.1 on CentOS7

Step 3: Check PHP version after installation

After you have installed it, you can check the PHP version again with the following command:

php -v

Below is the output after running the above command

Instructions for installing PHP 8.1 on CentOS7

As shown, I have successfully installed PHP 8.1 on CentOS 7 successfully.

Summary

So in this article, I showed you how to install PHP 8.1 on CentOS 7 in a very simple and fast way. PHP 8.1 will certainly bring many new utilities, thus helping applications or websites to operate with maximum efficiency and stability. Hope the article will help you, wish you success.