Current Location: Home> Latest Articles> Complete Guide to Installing PHP7 and Redis Extension on Ubuntu

Complete Guide to Installing PHP7 and Redis Extension on Ubuntu

gitbox 2025-08-05

Installing PHP7 on Ubuntu

PHP7 is a significant version of the PHP language, offering better performance and lower resource consumption. On Ubuntu, PHP7 can be easily installed using the apt package manager.

sudo apt-get install php7.0

After installation, verify it by running:

php -v

If the output shows PHP version 7.0.x, PHP7 has been installed successfully.

Installing the Redis Extension

Redis is a high-performance key-value database commonly used for caching and session management. PHP requires an extension to support Redis functionality. Below is the installation process.

Installing the PECL Package Manager

PECL is the PHP Extension Community Library package manager. It is required before installing the Redis extension:

sudo apt-get install php-pear

Installing the Redis Server

Install the Redis server with:

sudo apt-get install redis-server

Installing the Redis PHP Extension

Run the following command to install the Redis extension for PHP:

sudo pecl install redis

After installation, confirm the extension is loaded by running:

php -m | grep redis

If "redis" appears in the output, the extension is successfully installed.

Configuring PHP to Use the Redis Extension

After installing the extension, enable it in PHP's configuration file. Navigate to the PHP config directory and edit php.ini:

cd /etc/php/7.0/cli/
sudo nano php.ini

Add the following line:

extension=redis.so

Save and exit, then restart the PHP service to apply the changes:

sudo service php7.0-fpm restart

Following these steps, PHP7 and the Redis extension are successfully installed and configured on your Ubuntu system, ready for you to accelerate your PHP applications with Redis.