How to install Redis and Redis-PHP in DirectAdmin CentOS Linux VPS

How to install Redis and Redis-PHP in DirectAdmin CentOS Linux VPS

The following article will show you how to install Redis and Redis-PHP in a DirectAdmin CentOS Linux VPS.

What is DirectAdmin?

DirectAdmin is a powerful, web-based hosting control panel which makes managing websites, databases, e-mail accounts, ftp accounts and much more on your Linux VPS much easier and much faster. More information about DirectAdmin can be found on the official website at https://www.directadmin.com

What is Redis

Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

What is Redis-PHP

It is an extension for PHP which provides an API for communicating with the Redis key-value store.

PRE-REQUIREMENTS


0. SSH TO YOUR DIRECTADMIN LINUX VPS

First thing to do is to login to your DirectAdmin virtual server via SSH and optionally fire up a screen/tmux session. For example:

ssh YOUR_VPS_IP -p YOUR_VPS_SSH_PORT
screen -U -S redis-screen

1. UPDATE YOUR DIRECTADMIN LINUX VPS

Next, make sure your system is fully up-to-date by running the following yum command:

yum update

2. INSTALL AND CONFIGURE REDIS

Install the redis package using yum for example:

yum install redis

Once installed, restart the daemon and add it to your system’s startup using:

service redis restart
chkconfig redis on

And check if it’s up and running on the system by running the following command:

redis-cli MONITOR

3. INSTALL IGBINARY

Igbinary is a drop in replacement for the standard php serializer. Instead of time and space consuming textual representation, igbinary stores php data structures in compact binary form. Savings are significant when using memcached or similar memory based storages for serialized data. About 50% reduction in storage requirement can be expected. Specific number depends on your data.

Install it via pecl as in:

pecl install igbinary igbinary-devel

4. INSTALL PHPREDIS / REDIS-PHP

Next, install the Redis PHP extension (REDIS-PHP) using the following commands:

note that the filenames may change, so make sure you tune the commands to suit your needs

cd /opt/
wget https://github.com/nicolasff/phpredis/tarball/0ae592b
tar xzvf 0ae592b
rm -f 0ae592b
cd phpredis-phpredis-0ae592b/

/usr/local/bin/phpize
./configure --enable-redis-igbinary --with-php-config=/usr/local/bin/php-config
make -j 4
make install

5. CONFIGURE PHP FOR REDIS-PHP

Finally, configure your PHP server to use the newly installed PHP extensions by editing /usr/local/lib/php.ini and adding the following:

vim /usr/local/lib/php.ini

extension=igbinary.so
extension=redis.so

With all this in place, restart your Apache webserver using:

service httpd restart

and check whether the extensions are loaded in your PHP via:

php -m | grep -E 'redis|igbinary'

If you’re one of our Linux VPS Hosting customers we can help you install Redis and Redis-PHP in a DirectAdmin CentOS Linux VPS free of charge. Just contact us and some of our experts will complete your request immediately.

One thought on “How to install Redis and Redis-PHP in DirectAdmin CentOS Linux VPS

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>