Home  >  Article  >  Database  >  How to install redis and php extensions under lunix

How to install redis and php extensions under lunix

WBOY
WBOYforward
2023-05-27 14:40:06811browse

  1. 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
  1. Install PHP extension

##After installing Redis, you need to install the Redis extension integrated with PHP.

First you need to confirm that PHP has been installed. You can use the following command to check:

php -v

If PHP is already installed, you can use the following command to install the Redis extension:

sudo apt-get install php-redis

After 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.ini

Find the following content in the opened configuration file:

;extension=redis.so

Remove the semicolon to enable the Redis extension:

extension=redis.so

Save the file and exit. Next, you need to restart the Apache server for the update to take effect:

sudo service apache2 restart

After 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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete