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.
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.
PECL is the PHP Extension Community Library package manager. It is required before installing the Redis extension:
sudo apt-get install php-pear
Install the Redis server with:
sudo apt-get install redis-server
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.
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.