This tutorial will help you with the installation of the Redis server along with PHP Redis PHP extensions on a CentOS 7/6 server.
Step 1 – Prerequisites
First of all, log in to your server using shell access with the root account. Redis packages are not available under default yum repositories. You need to enable EPEL yum repository on your server first. Execute below command to enable:
Step 2 – Install Redis Server
Now, You can use the yum package manager to install the Redis server on a VPS. Execute command to install Redis on your systems: After successfully installation start Redis service and enable auto-start on system reboot. Redis server is up and running on your system.
Step 3 – Install Redis PHP extension
We assume you already have PHP installed on your system. You must have PHP pear package installed on your system. Now, execute commands to enable Redis PHP extension on your CentOS server. After that execute a command to verify Redis PHP extension is enabled: Redis server has been installed on your system along with the PHP extension.
Step 4 – Configure Redis as a Cache Server
Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes Update the following values in the Redis configuration file according to your requirement. You can increase the max memory limit as per available on your server. The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:
Step 5 – Test Connection to Redis Server
Use redis-cli tool to verify the connection between the Redis server and redis-cli.