Learn how to install Redis and Redis-PHP in DirectAdmin. Our Redis Support Team is here to help.
Install Redis and Redis-PHP in DirectAdmin like a Pro
As every citizen of the digital world knows, website speed plays a critical role in both user experience and SEO performance. One powerful way to boost WordPress performance is by enabling Redis object caching. Redis stores frequently accessed data directly in memory, reducing database queries and speeding up page loads significantly.
Today, we will look at how Redis-PHP works, and step-by-step instructions to install and configure Redis on a server using DirectAdmin and CustomBuild 2.x.
An Overview
A Quick Introduction to Redis & Redis-PHP
Redis is an open-source, in-memory data store that can be used as both a database and a caching layer. Instead of storing cached data on a hard drive (which is slower), Redis keeps it in RAM, ensuring lightning-fast access.
In WordPress, Redis integrates with `WP_Object_Cache`. This allows the server to quickly fetch processed data without repeatedly querying the PHP engine or database. The result? Faster performance, reduced load times, and improved resource efficiency.
For developers exploring such use cases, check out this detailed guide on setting expire time with Python Redis HSET.
Redis-PHP is a PHP extension that provides an API for communication between PHP applications (like WordPress) and the Redis key-value store. Essentially, it’s the bridge that makes Redis caching possible for WordPress websites.
Prerequisites
Before proceeding, ensure that:
- Run running DirectAdmin with CustomBuild 2.x
- Redis is installed or available for installation in DirectAdmin.
- We need SSH access (for command-line installation and configuration)
If we are on a managed hosting plan, contact the provider to enable Redis on your hosting account.
How to Enable Redis in DirectAdmin
- First, log in to DirectAdmin as a user. Then, go to Advanced Features > Redis.
- Next, enable Redis and copy the path to the Redis socket file. We will need this later.
- Now, go to Select PHP Version under Extra Features.
- Then, check the box for Redis under Extensions.
- Next, we have to log in to the WordPress site.
- Then, install and open the LiteSpeed Cache plugin.
- Now, go to Cache > Object tab and configure:
- Set Object Cache = ON
- Method = Redis
- Host = Path to socket file (copied earlier)
- Port = `0`
- Save changes.
- Next, we need to verify the Status:
- Redis Extension = Enabled
- Connection Test = Passed
Install Redis via Command Line
For users with root access, Redis can be installed manually:
# Connect via SSH
ssh root@xx.xx.xx.xx -p xxxx
# Open a screen session
screen -U -S redis
# Update the server
yum update
# Install Redis
yum install redis
# Start Redis service
service redis start
# Enable on boot
chkconfig redis on
# Verify Redis is running
redis-cli MONITOR
If you need to connect to a Redis instance remotely with authentication, you can follow this guide on connecting to Redis CLI with a password.
.
Configure Redis
Fine-tuning Redis improves stability and persistence:
- Edit the Redis configuration file:
vi /etc/redis.conf
- Then, set the following values:
appendonly yes
appendfsync everysec
- Next, restart Redis:
service redis restart
- Now, update Linux kernel memory settings:
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
Remember to make sure the system has swap memory configured. Without it, Redis may crash if it consumes more memory than available.
Install Igbinary for Better Performance
By default, PHP uses a text-based serializer. For higher efficiency, Igbinary can be used instead. It stores PHP data structures in compact binary form, saving up to 50% memory when used with Redis.
- First, install Igbinary:
pecl install igbinary igbinary-devel
- Then, install the Redis PHP extension:
cd /opt/
wget https://github.com/nicolasff/phpredis/tarball/0ae592b
tar xzvf 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
Configure PHP for Redis-PHP
- To edit `php.ini`, run:
vi /usr/local/lib/php.ini
- Then, add:
extension=igbinary.so
extension=redis.so
- Now, restart Apache:
service httpd restart
- To confirm installation:
php -m | grep -E ‘redis|igbinary’
While Redis is stable, some users may encounter configuration or cluster-related errors. For example, if you’re running benchmarks and see a MOVED error, it’s often tied to cluster node redirections. This article explains how to troubleshoot the Redis benchmark error from server moved in detail.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
Redis is a powerful caching solution that can drastically improve WordPress performance. By storing object cache in memory instead of relying solely on the database, Redis reduces server load, accelerates page delivery, and ensures better scalability.
In brief, our Support Experts demonstrated how to install Redis and Redis-PHP in DirectAdmin.
0 Comments