WINDOWS32 Install redis+ connect PHP

Source: Internet
Author: User
Tags ini phpinfo redis vc9 install redis redis server
Spent two days, read the countless Chinese code, and finally on their own notebook loaded with Redis, below the tutorial.
First of all, do not understand redis Why use the Please first Baidu ...
Download the Redis windows32 bit client: http://pan.baidu.com/s/1qWAp8He
After downloading the proposed extract to the Web directory, such as: D:wwwredis
In order to eliminate the hassle of using CMD to enter the folder, you can go directly to your Redis folder shift+ the right mouse button (as shown on the right)
Then enter the following instructions (redis.conf for the Redis configuration file, there is a need to be modified after the operation, this is my copy from the Internet to change the good to use):
If you can see cmd displaying the following, congratulations, your Redis server is already available:
Later to use this command can be used to open redis, of course, Windows can not be closed, close the window Redis will stop running.
Then, establish a PHP to Redis connection so PHP can send data directly to Redis:
Please run phpinfo () to view the following: PHP version number, TS or NTS, VC version
Please select the corresponding version download
PHP5.4-TS-VC9 (I used the XAMPP, so slightly different)
PHP5.3-TS-VC9 (Wamp's general Use this)
After downloading, please copy the extracted DLL files to the Php/ext directory, for example, my d:xamppphpext,wamp can not think of a specific path, please search the folder directly. (PHP5.4 requires two to use together, so I have two DLLs)
Then you can modify the php.ini, and after you see a lot of Extension=xxxxx.dll, add the following (the effect is to have Apache load the corresponding extension at startup):
PHP5.4: (order cannot be reversed)
Extension=php_igbinary.dll
Extension=php_redis.dll
PHP5.3: (with Wamp note, take a look at the real call path to the Configuration of loaded php.ini file field in your Phpinfo, by default php.ini is to load the php.ini under Apache)
Extension=php_redis.dll
Save the restart Apache after the field has been added (no reboot is not loaded) and then look at your phpinfo inside is not able to search to Redis expansion, if the search to congratulate you, extended load success can then next, if the search is not also congratulations, go back to check which steps out of the problem. (as in the picture, the version is different can not tangle)
End, test:
Create a new PHP file and enter the code
The code is as follows Copy Code
<?php
/**
*
* Project name: Test
* Create person: www.111cn.net Zoa_chou
* Date Created: 2014-3-3
*
*/
$redis = new Redis ();
$redis->connect (' 127.0.0.1 ', 6379);
$redis->connect ("test.com", 6379); IP and port set by PHP client
Store a value
$redis->set ("Say", "Hello World");
echo $redis->get ("say"); Should output Hello World
Storing multiple values
$array = Array (' First_key ' => ' first_val '),
' Second_key ' => ' second_val ',
' Third_key ' => ' third_val ');
$array _get = Array (' First_key ', ' second_key ', ' Third_key ');
$redis->mset ($array);
Var_dump ($redis->mget ($array _get));
?>
Save, run. If you see the picture below, congratulations, start enjoying your redis!

PS: The next issue may share your own encapsulated Redis class or some redis usage.

is followed by a Wamp installation method

1, extracting Win_redis.rar to E:, and setting E:win_redis to an environment variable.
2, copy Php_redis.dll to PHP's ext folder, modify php.ini add Extension=php_redis.dll.
3, restart Apache, and check phpinfo see Redis module loaded successfully.
4, double-click the installation directory to Redis-server.exe to start the Redis caching service.
5, double-click the installation directory under Redis-cli.exe, you can open the cache client.

Above 4, 5 steps can be performed using a batch file:
Create a new TXT document, write the following script in the document, and save it.
1 start "Redis-server"/min cmd/c redis-server e:win_redisredis.conf
2 start "redis-client"/min cmd/ C REDIS-CLI
The last txt document to be saved, rename the bat type, and the next time you double-click the bat file to run the caching service, we can also add this bat batch file to the boot entry, no longer listed here.

Note: The two windows after the cache service is turned on cannot be closed, or the service stops, and the caching service can only be used when the service is started.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.