Install redis extension for PHP under Windows

1. Use the phpinfo() function to view the PHP version information, which will determine the extension file version.

2. Download php_igbinary-2.0.1-7.0-ts-vc14-x64.zip, php_redis-3.1.3rc2-7.0-ts-vc14-x64.zip (must ensure the correct version)

Download address: [Select the appropriate version]

http://windows.php.net/downloads/pecl/snaps/redis/

http://windows.php.net/downloads/pecl/releases/igbinary/

ps: If you see php7ts.dll in the PHP directory, select the ts version

3. After decompression, copy php_redis.dll and php_redis.pdb to the ext directory of php

4. Modify php.ini, (PS: this php.ini file is in the Apache directory) and add:

; php_redis

extension=php_igbinary.dll

extension=php_redis.dll

Note: extension=php_igbinary.dll must be placed in front of extension=php_redis.dll, otherwise this extension will not take effect

5. After restarting Apache, use phpinfo to check whether the extension is successfully installed

6. After opening the redis service, you can use the following test to test whether it can be called.

1

2

3

4

5

6

7

8

9

10

<?php

 //连接本地的 Redis 服务

 $redis = new Redis();

 $redis->connect('127.0.0.1', 6379);

echo "Connection to server sucessfully";

 //设置 redis 字符串数据

 $redis->set("tutorial-name""Redis tutorial");

 // 获取存储的数据并输出

 echo "Stored string in redis:: " . $redis->get("tutorial-name");

?>

  ps: The local redis service must be enabled before running [download address: https://redis.io/download]

In fact, Redis can be installed as a windows service, and it starts automatically at boot. The command is as follows:

1

redis-server --service-install redis.windows.conf

After installation, you can see that redis has been used as a windows service:

But after installation, Redis did not start,

The startup command is as follows:

1

redis-server --service-start

stop command:

1

redis-server --service-stop

Multiple instances can also be installed

1

2

3

4

5

6

redis-server --service-install –service-name redisService1 –port 10001

redis-server --service-start –service-name redisService1

redis-server --service-install –service-name redisService2 –port 10002

redis-server --service-start –service-name redisService2

redis-server --service-install –service-name redisService3 –port 10003

redis-server --service-start –service-name redisService3

Uninstall command:

1

redis-server --service-uninstall

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325606440&siteId=291194637