Install Redis and Redis-PHP in DirectAdmin
Redis is a database management system, used as the message broker, cache and in-memory data structure store. It is usually referred to as a data structure server, in fact, the keys can contain strings, hashes, lists, sets, and sorted sets. Redis is developed in ANSI C and runs in most POSIX systems. We can enable atomic operations on these types, like computing set intersection, appending to a string, pushing an element to a list, incrementing the value in a hash.
1) SSH to the server.
#ssh firstname.lastname@example.org -p xxxx
2) Then you need to open a screen section using the command.
#screen -U -S name
3) Make sure that your server is up-to-date by running the following command
4) Install the redis package using:
#yum install redis
5) Now the system will install redis, then start the daemon.
#service redis start
6) Set Redis to automatically start on boot.
#chkconfig redis on
7) Check if redis is up and running on the system by using the following command.
Configure some basic persistence and tuning option for redis.
1) Set the following values for the appendonly and appendfsync settings in redis.conf.
2) Restart redis.
#service redis restart
You need to set the Linux kernel overcommit memory setting to 1.
In /etc/sysctl.conf we need to add vm.overcommit_memory = 1 and then reboot or run the command sysctl vm.overcommit_memory=1 for this to take effect immediately.
Make sure to set up some swap in your system (we suggest as much as swap as memory). Because if Redis instance accidentally consumes too much memory and your system does not have much swap, either the Redis will crash or the Redis process will be killed by the Linux kernel OOM killer.
We can use Igbinary instead of the standard php serializer because Igbinary is a drop in replacement for the standard php serializer. Igbinary stores php data structures in compact binary form rather than saving as a textual representation which consumes more time and space. When using Memcached or similar memory based storages for serialized data savings are significant. The 50% of the storage use can be decreased.
1) Install Igbinary via pecl.
#pecl install igbinary igbinary-devel
2) Install the Redis PHP extension.
# cd /opt/
# tar xzvf 0ae592b
# rm -f 0ae592b
# cd phpredis-phpredis-0ae592b/
# ./configure –enable-redis-igbinary –with-php-config=/usr/local/bin/php-config
# make -j 4
# make install
Configure PHP for Redis-PHP
1) Add the following extensions to /usr/local/lib/php.ini.
# vi /usr/local/lib/php.ini
2) Restart Apache web server.
# service httpd restart
3) Check whether it is loaded in the PHP :
# php -m | grep -E ‘redis|igbinary’
If you need any further help, please do reach our support department.