Home > Article > Backend Development > The whole process of installing redis extension and redis testing and using php7.X under windows (phpstudy, wamp, xampp)
The content of this article is about the installation of redis extension and the whole process of redis test and use (phpstudy, wamp, xampp) under windows with php7. Let’s take a look
1. Redis extension installation configuration in PHP
1. First of all, and the most important point is that you need to know your PHP version information, which will determine your extension file Version. One thing to remember in particular is that the choice of x64 or x86 for redis is determined by whether the PHP version of Architecture is x64 or x86, and has nothing to do with the Windows operating system. This example is the phpstudy integrated environment. The result of using the phpinfo() function to print out the PHP version information is as follows:
Here, you can clearly see that architecture The structure is x86, so redis should be selected as x86 (this is also the reason why I failed to install life and death at the beginning). OK, after knowing the version information of php, we will download the corresponding redis. The download address is: https://pecl.php.net/package/redis.
2 Enter the download address and you can see some information about the redis version. There are instructions for the latest version of redis, two beta versions and a stable version. Here, we use the stable version.
Since my php version is: php version 7.1.8, which meets the conditions of the latest version of redis, so I choose the latest version of redis (according to my own php version Information, just choose the redis version that suits you).
Click to enter the DLL page and you can see the redis information of this version. If you find it troublesome, you can jump directly to the DLL List entry:
Here, there are several different formats to choose from, if you don’t know which choice to make Which one can be seen in Figure 1 above. First, the PHP version is 7.0.12, so PHP 7.0 should be selected. Secondly, as can be seen in Figure 1, PAPI20151012,NTS,VC14, so the NTS item should be selected. Then its Architecture is x86, so you need to select the x86 format. (Although my windows is x64, this has nothing to do with the redis version selection, so don’t be misled). Therefore, download the 7.0 Non Thread Safe (NTS) x86 version
3 After unzipping, copy php_redis.dll to the ext directory of php. Some people say that you need to copy php_redis.pdb to the ext directory, but I have personally practiced it. You only need to copy php_redis.dll to the ext directory of php (this may be due to the php version. You should base it on your actual situation. situation, flexible handling).
4 Modify php.ini and add:
; php_redis
1 Download from github website. The download address is: https://github.com/dmajkic/redis/downloads
2 Install it according to the actual situation (that is, copy the corresponding files to the custom directory according to the actual situation). If your operating system is 64-bit, choose 64-bit.
court to - to switch to the Redis-server.exe directory , run redis-server.exe redis.conf; the following figure indicates successful startup:
4 Do not close the original window (if closed, redis cannot be accessed) Server), open a new window, switch to the redis directory and run redis-cli.exe -h 127.0.0.1 -p 6379. As shown below, you can see that redis-cli started successfully:
5 Use redis to test, and the result proves successful:
三 Test in Thinkphp3.2. At this time, redis-server cannot be closed, otherwise an error will occur. The code is as follows:
$redis = new \Redis(); $redis->connect(C('REDIS_HOST'), C('REDIS_PORT')); $redis->set('myname', 'yourname'); //设置值 $res = $redis->get('myname'); echo $res;The final output result is
youname
, indicating that the installation of redis has been successful.It should be noted that if you are debugging and installing in a PHP7 environment, you need to note that the mysql configuration needs to be configured as mysqli
Linux installs Redis for PHP Extension method
Instance code for installing redis extension in yii2.0 framework
The above is the detailed content of The whole process of installing redis extension and redis testing and using php7.X under windows (phpstudy, wamp, xampp). For more information, please follow other related articles on the PHP Chinese website!