Users on cPanel manage a server based on Linux, requiring the installation of both Redis and PHP Redis. This software is crucial for developers constructing projects with PHP.
Redis serves as a potent open-source, in-memory data structure store, functioning as a key-value store housing strings, hashes, lists, sets, and sorted sets. Leveraging Redis facilitates the seamless storage of substantial data volumes without compromising data transfer performance. Its passive data caching mechanism efficiently clears the cache of outdated content when updating with new information.
Installing Redis:
-
Access your cPanel server by logging in via SSH.
-
Execute the following commands to download the RPM files for Redis.
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
-
Input and execute the following commands to install Redis:
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# yum install –y redis
Upon completing these steps, Redis will be successfully installed on your server.
-
Execute the following command to enable Redis:
# chkconfig redis on
Enabling this setting will ensure that Redis starts automatically upon a server reboot.
Now that the installation is complete, let's proceed to configure Redis.
-
Access the redis.conf file and add/copy the following lines to the end of the file:
vi /etc/redis.conf
maxmemory 256mb
maxmemory-policy allkeys-lru
This will establish the fundamental configurations for Redis on your server. Subsequently, it's time to proceed with installing the PHP Redis extension.
Installing PHP Redis:
-
Access WHM with root access.
-
Choose the Software option from the navigation menu.
-
Select Module Installers.
-
Choose "Manage" for PHP Pecl.
The PHP Pecl Installer section will appear.
Could you find the area labeled "Find a PHP PECL"?
-
Enter "redis" in the Search box and click Go.
-
The search results will display the relevant PHP Redis module. Click on Install.
This will install the PHP extension, serving as an interface for Redis.
7. To finalize, execute the following commands in SSH:
# service httpd restart
# service redis restart
This restarts Redis and httpd, ensuring the changes take effect. With this, the installation of Redis and PHP Redis on your cPanel server is now complete.