Installing Redis
First, you need to install Redis in the Linux system. The installation can be completed through the following command:
sudo apt-get install redis-server
After the installation is completed, you can use the following command to check whether the Redis service has been started:
sudo service redis-server status
If the service has been started, results similar to the following will be output. :
redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-10-27 11:17:38 CST; 2 days ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 4187 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS) Process: 4188 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Main PID: 4223 (redis-server) Tasks: 4 (limit: 4915) CGroup: /system.slice/redis-server.service └─4223 /usr/bin/redis-server 127.0.0.1:6379
Install PHP extension
php -vIf PHP is already installed, you can use the following command to install the Redis extension:
sudo apt-get install php-redisAfter the installation is complete, you need to add the Redis extension to the PHP configuration file. You can use the following command to open the PHP configuration file:
sudo vi /etc/php/7.0/apache2/php.iniFind the following content in the opened configuration file:
;extension=redis.soRemove the semicolon to enable the Redis extension:
extension=redis.soSave the file and exit. Next, you need to restart the Apache server for the update to take effect:
sudo service apache2 restartAfter completing the above steps, the Redis extension has been integrated into PHP, and you can happily use Redis for development!
The above is the detailed content of How to install redis and php extensions under lunix. For more information, please follow other related articles on the PHP Chinese website!