The content of this article is the use of Redis and PHP under windows. I share it with everyone here and give a reference to friends in need.
Environment: Windows7 x64 Apache2.4 PHP5.6 mysql5.5
Materials: redis plug-in and redis server Software
Download address: redis plug-in http://windows.php.net/downloads/pecl/releases/redis/2.2.7/php_redis-2.2.7-5.6-ts-vc11-x64.zip
We can also download the redis plug-in corresponding to the PHP version according to our own needs
First enter the PHP official website
www.php.net->Select Downloads- in the navigation >Select any windows downloads in the page that appears->Select PECL extensions
in the PECL For Windows block in the page that appears->Select Download Statistics in the new page that appears-> Search for redis in the page that appears, and click the link after finding it ->Select the DLL link in the page that appears->Select the corresponding version of the
Redis extension
at the bottom of the page that appears. After downloading, you will get a ZIP compressed package. After decompression, copy the .DLL file to the ext folder in the PHP installation directory.
The extension has been obtained. Next, we download the redis server software
Download address: https://github.com/dmajkic/redis/downloads
I just downloaded the 2.2.7 plug-in, so the server I choose now must be greater than 2.2.7, but considering For version compatibility, I used the 2.2.12 version of the server
to get a zip package. After decompression, I got two versions of the server software. I used x64 and changed the folder name to redis
Let the redis server run first, open the Windows cmd window, and switch to the redis directory
Then save and restart the Apache serverThen write a test code to test it $redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->set('string','hello redis'); echo $redis ->get('string');?>If you want the test to be successful, you must ensure that the command line window running redis is still open, that is, the redis service is still running. The test can be successful or the test fails! Related recommendations:
Redis cluster implementation and calling using php - CSDN blog
php command sharing for operating redis
The above is the detailed content of Using Redis+PHP under windows. For more information, please follow other related articles on the PHP Chinese website!