Home > Article > Backend Development > A complete guide to installing Redis extensions on Linux
Complete guide to installing Redis extensions under Linux system
Redis is an open source, high-performance key-value storage database that is widely used in Scenarios such as caching and message queues. Installing the Redis extension under the Linux system allows us to use the Redis database more efficiently. This article will introduce in detail how to install the Redis extension under Linux system and provide specific code examples.
sudo apt update sudo apt install redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server
sudo apt-get install php-redis
sudo nano /etc/php/7.4/cli/php.ini
Add the following content at the end of the file:
extension=redis.so
Save and exit.
sudo systemctl restart php7.4-fpm
test_redis. php
, enter the following code: <?php $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->set('test_key', 'Hello, Redis!'); echo $redis->get('test_key'); ?>
php test_redis.php
If everything goes well, Hello, Redis!
, indicating that the Redis extension has been successfully installed and connected to the Redis server.
Through the above steps, you have successfully installed the Redis extension under the Linux system and conducted a simple test. Now you can use Redis database in PHP projects to improve performance and efficiency. Hope this article is helpful to you!
The above is the detailed content of A complete guide to installing Redis extensions on Linux. For more information, please follow other related articles on the PHP Chinese website!