How to Install Redis and PHP Redis on a cPanel Server?

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:

  1. Access your cPanel server by logging in via SSH.

  2. 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

  1. 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.

  1. 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.

  1. 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:

  1. Access WHM with root access.

  2. Choose the Software option from the navigation menu.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/whm_software.png

  1. Select Module Installers.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/06/whm_mod_install.png

  1. Choose "Manage" for PHP Pecl.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/06/whm_pecl_manage.png

The PHP Pecl Installer section will appear.

Could you find the area labeled "Find a PHP PECL"?

  1. Enter "redis" in the Search box and click Go.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/whm_php_pecl_installer_redis_go.png

  1. The search results will display the relevant PHP Redis module. Click on Install.

https://www.milesweb.in/hosting-faqs/wp-content/uploads/2021/10/whm_php_pecl_installer_redis_install.png

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.


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 398