DEV Community

Dylan Lopez
Dylan Lopez

Posted on

How To Install PHP 8.1 on CentOS 7

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.

Step 1: Add EPEL and REMI Repository
Run the commands below to add required repositories.

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
Enter fullscreen mode Exit fullscreen mode

Step 2: Install PHP 8.1 on CentOS 7

yum -y install yum-utils
yum-config-manager --enable remi-php81
Enter fullscreen mode Exit fullscreen mode

Use the next command to install additional packages:

yum install php-xxx

// Example

yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
Enter fullscreen mode Exit fullscreen mode

The current PHP version should be 8.1.

php -v
Now you have PHP 8.1

Top comments (0)