How to Install Redis and PHP Redis on a cPanel Server

Redis is an open-source, in-memory data structure store that's commonly used as a database, cache, and message broker. Installing Redis on a cPanel server can enhance performance, especially for web applications that rely heavily on caching. This guide will walk you through installing Redis and PHP Redis (for PHP integration) on a cPanel server.

Step 1: Install Redis on Your cPanel Server

  1. Access SSH
    Connect to your cPanel server via SSH. You need root privileges to install Redis.


  1. Update the Package Repository
    Update your package manager to ensure you have access to the latest Redis version:

yum update -y


  1. Install Redis
    Use the following command to install Redis on your server:

yum install redis -y


  1. Enable and Start Redis
    After installation, enable and start Redis to run it automatically on system startup.

systemctl enable redis

systemctl start redis


  1. Check Redis Status
    Confirm that Redis is running by checking its status:

systemctl status redis


Step 2: Install PHP Redis Extension

To integrate Redis with PHP, you'll need the PHP Redis extension.

  1. Install PHP Development Tools
    Before installing the PHP Redis extension, ensure PHP development tools are installed:

yum install php-devel -y



  1. Install PHP Redis Extension
    Use PECL (PHP Extension Community Library) to install the PHP Redis extension:

pecl install redis



  1. Enable the PHP Redis Extension
    After installation, add the Redis extension to your PHP configuration:

echo "extension=redis.so" > /etc/php.d/redis.ini


  1. Restart Apache
    Restart Apache to apply the changes:

systemctl restart httpd



Step 3: Verify Redis and PHP Redis Installation

  1. Verify Redis Installation
    Test Redis by running the following command:

redis-cli ping


If Redis is running correctly, it should return "PONG."


  1. Verify PHP Redis Extension
    Create a PHP file in your public_html directory to verify PHP Redis. Add the following code to the file:

phpinfo();

?>


Access this file in your web browser. Search for "Redis" on the page to confirm the PHP Redis extension is installed and active.

Step 4: Configure Redis (Optional)

For enhanced security and performance, consider configuring Redis. For example, you can set a password for Redis or adjust the memory limit by editing the Redis configuration file:

nano /etc/redis.conf



After making changes, restart Redis to apply:

systemctl restart redis



Conclusion

With Redis and PHP Redis now installed, your cPanel server can efficiently handle caching and data management, significantly improving performance for PHP-based applications.


Was this answer helpful? #0 #0
 

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Related Questions

Submit your Query

  • I'm not a robot

Browse by ServicesBrowse by Services

Resource Library

What is Cloud Computing

Understand the term cloud computing, the ongoing trend, its playing field, future growth and how industry...

Myths about Cloud Computing

Cloud computing, in the recent years, has become a subject of significant discussion among the industry experts.

Download Now

Did We Miss Out on Something?

Relax, we have you covered. At Go4hosting, we go the extra mile to keep our customers satisfied. We are always looking out for opportunities to offer our customers “extra” with every service. Contact our technical helpdesk and we’d be more than happy to assist you with your Cloud hosting, Colocation Server, VPS hosting, dedicated Server or reseller hosting setup. Get in touch with us and we’d cover all your hosting needs, however bizarre they might be.

Submit Query

Please fill in the form below and we will contact you within 24 hours.