> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Redis on managed servers

> Learn how to configure Redis to boost site performance on managed VPS, Dedicated servers, Turbo Boost, Turbo Max, or Turbo Reseller Hosting accounts.

This article describes how to use [Redis](https://redis.io/) on the following hosting packages:

* Managed VPS
* Managed Dedicated server
* Turbo shared and reseller hosting accounts

Redis is an open-source memory object caching system that web sites can use to help accelerate page load times. Redis caches in RAM frequently accessed data, such as the results of API calls, database calls, and more.

Redis can significantly help improve site performance.

## Managed VPS and Dedicated servers

Redis is installed and ready to use on managed VPS and managed Dedicated servers.

### Connection parameters

You can connect to Redis using the following parameters:

* **Hostname:** *localhost*
  > 👍 Tip
  >
  > Alternatively, you can use the IP address *127.0.0.1*.
* **Port:** *6379*

### Diagnostics

To verify Redis is running, type the following command:

```bash theme={null}
systemctl status redis
```

You can also use the *redis-cli* program to connect to Redis directly.

For example, the following commands demonstrate how to use\_redis-cli\_ to dump all of the cached key-value pairs, and then display rolling statistics for Redis:

```bash theme={null}
redis-cli KEYS '*'
redis-cli --stat
```

<Tip>
  To clear the entire Redis cache at once, type the following command:

  ```bash theme={null}
  redis-cli FLUSHALL
  ```
</Tip>

### Code sample

There are numerous PHP libraries available for integration with Redis. The following procedure demonstrates how to use the [Predis library](https://github.com/predis/predis) to connect to Redis and store a key/value pair:

1. Log in to your server [using SSH](/docs/using-ssh-secure-shell).
2. At the command prompt, type the following commands:

```bash theme={null}
cd ~
composer require predis/predis
```

3. Using your preferred text editor, create a file named *redis-test.php*. Copy and then paste the following code into the *redis-test.php* file:

```text theme={null}
<?php

require './vendor/predis/predis/autoload.php';

Predis\Autoloader::register();
$client = new Predis\Client();

$client->set('test', 'hello');
$value = $client->get('test');

print "test = " . $value . " ";
?>
```

4. Save your changes to the *redis-test.php* file.
5. Type the following command to run the script:

```bash theme={null}
php redis-test.php
```

6. You should receive the following output:

```text theme={null}
test = hello
```

<Tip>
  To confirm the key/value pair is stored in the Redis cache, type the following command:

  ```bash theme={null}
  redis-cli GET test
  ```
</Tip>

For more information about how to use PHP with Redis, please visit [https://redis.io/docs/latest/develop/clients/php/](https://redis.io/docs/latest/develop/clients/php/).

## Turbo shared and reseller hosting accounts

To connect to Redis on a Turbo shared hosting account, use the following Unix socket path. Replace ***username*** with your own account username:

**/home/username/.redis/redis.sock**

To verify that the Redis socket is active for your account, type the following command. Replace ***username*** with your own account username:

```bash theme={null}
ls -l /home/username/.redis/redis.sock
```

If you receive a **No such file or directory** error message, then the socket has not been activated for your account yet. To do this, type the following command:

```bash theme={null}
touch ~/.redis.on
```

The server checks for this file every five minutes, and starts the Redis process for the account if it does not already exist. After five minutes, run the **ls** command above again, and you should see the *redis.sock* file in the directory listing.

<Warning>
  **Important**

  Before you try to use Redis with PHP on your account, make sure the correct PHP extension is enabled. To do this, follow these steps:

  1. Log in to cPanel.
  2. In the **SOFTWARE** section of the cPanel home screen, click **Select PHP Version**.
  3. In the list of PHP extensions, confirm that the **Redis** check box is selected. (If you do not see a list of PHP extensions, click the **Extensions** tab.)
</Warning>

### Code sample

The following PHP code demonstrates how to connect to Redis and store a key-value pair in the cache.

<Warning>
  **Important**

  If you run this code, remember to replace ***username*** with your own account username.
</Warning>

```text theme={null}
<?php

$redis = new Redis();
$redis->connect('/home/username/.redis/redis.sock');

$redis->set('test', 'hello');
$value = $redis->get('test');

print "test = " . $value . " ";
?>
```

When you run this script, you should receive the following output:

```text theme={null}
test = hello
```

<Tip>
  To confirm the key/value pair is stored in the Redis cache, type the following command:

  ```bash theme={null}
  redis-cli -s ~/.redis/redis.sock GET test
  ```

  Note that you must explicitly provide the socket path to *redis-cli*, or the command will fail.
</Tip>

## Using Redis with web applications

A frequent use for Redis is to help improve performance in a CMS (content management system) like WordPress or Drupal. Redis can also help accelerate performance in e-commerce applications like PrestaShop or Magento:

* For information about how to configure **WordPress** to use Redis, please see [this article](/docs/configuring-wordpress-to-use-redis).
* For information about how to configure **Drupal** to use Redis, please see [this article](/docs/configuring-drupal-to-use-redis).
* For information about how to configure **Joomla** to use Redis, please see [this article](/docs/configuring-joomla-to-use-redis).
* For information about how to configure **PrestaShop** to use Redis, please see [this article](/docs/configuring-prestashop-to-use-redis).
* For information about how to configure **Magento** to use Redis, please see [this article](/docs/configuring-magento-to-use-redis).

## More information

* For more information about Redis, please visit [https://redis.io](https://redis.io).
* For more information about how to use PHP with Redis, please visit [https://redis.io/docs/clients/#php](http://redis.io/docs/clients/#php).
* For more information about the Predis PHP library for Redis, please visit [https://github.com/predis/predis](https://github.com/predis/predis).

## Related articles

* [Do you support Redis?](/docs/do-you-support-redis)
* [Configuring WordPress to use Redis](/docs/configuring-wordpress-to-use-redis)
* [Using memcached on managed servers](/docs/using-memcached-on-managed-servers)
* [Configuring Joomla to use Redis](/docs/configuring-joomla-to-use-redis)
* [Configuring Drupal to use Redis](/docs/configuring-drupal-to-use-redis)
* [Configuring PrestaShop to use Redis](/docs/configuring-prestashop-to-use-redis)
* [Configuring Magento to use Redis](/docs/configuring-magento-to-use-redis)
* [Enabling the Redis extension for PHP](/docs/enabling-the-redis-extension-for-php)
