Article directory
In modern websites and applications, memory caching technology has become one of the key tools to improve performance.
Redis , as a popular in-memory data structure storage system, is widely used in scenarios such as caching, session management, and data storage.
This article will detail how to install and configure Redis memory caching on HestiaCP , including the steps for installation on Debian or Ubuntu systems, configuring the Redis service, and understanding the differences between Redis and php-redis.

1. Install Redis using the official repository
Redis is not always available in the default software repositories of Debian or Ubuntu , or it may provide an older version. To get the latest version of Redis, you need to add the official Redis repository and install it. Here are the specific steps:
Import the Redis official GPG key
wget -O /usr/share/keyrings/redis-archive-keyring.gpg https://packages.redis.io/redis-archive-keyring.gpgAdd Redis official repository
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.listUpdate package lists
sudo apt updateInstall Redis and the php-redis extension
sudo apt install redis php-redis
In this way, you can install the latest version of Redis from the Redis official repository.
If you are using PHP 8.2, install the Redis extension using the following command:
apt install php8.2-redis
systemctl restart php8.2-fpm2. Check the Redis service status
After installation, you can check if the Redis service is running normally. Depending on your Linux distribution, you can use the following command:
Systems using systemd
systemctl status redisSystems using init.d
/etc/init.d/redis-server statusView Redis version information
redis-cli --versionTesting the Redis Server Connection
redis-cli pingIf Redis is running, you should receive
PONGResponse.
3. Securely configure Redis
To improve the security of Redis, the following measures are recommended:
Add a password
Set a password in the Redis configuration file to prevent unauthorized access.
Restrict access
Restrict access to the Redis service to specific IP addresses or networks.
Using Sockets
Use sockets instead of TCP ports for increased speed and security.
4. The difference between php-redis and Redis
When installing Redis, you may also see php-redis This extension. They differ in the following ways:
php-redis
php-redisIt is a PHP extension that allows PHP scripts to interact with the Redis server.php-redisAfter that, PHP applications can take advantage of Redis's caching, session management, and queue handling capabilities.php-redisIt does not contain a Redis server itself, it is just a bridge between PHP and Redis.Redis
Redis is a standalone service that runs the Redis database. It runs in the background as a daemon process, providing data storage and caching services. Other applications, including
php-redisExtended PHP applications can connect to the Redis server through the network to operate.
in short,php-redis It is a PHP extension used to operate Redis in PHP applications; while Redis is an independent service that provides memory data storage capabilities.
If you want to use Redis in your PHP application, you need to install both the Redis server and php-redis Extension so that PHP applications can php-redis The extension communicates with Redis.
in conclusion
Installing and configuring Redis memory cache on HestiaCP can significantly improve the performance of your websites and applications.
By following the steps in this article to add the official repository and install Redis, you will be able to get the latest version of Redis.
How do I configure Redis for multiple WordPress websites on the same server?
Ensure you check the Redis service status and perform necessary security configurations to guarantee system stability and security.
Understanding php-redis The differences between Redis and REST will help you better configure and utilize the functions provided by Redis, and further improve your development and operation efficiency.
Hopefully, the article "How to Install Redis Memory Cache with HestiaCP? Detailed Steps from 0 to 1" shared on Chen Weiliang's blog ( https://www.chenweiliang.com/ ) will be helpful to you.
Feel free to share this article's link: https://www.chenweiliang.com/cwl-31961.html

