Redis development tutorial for Redis and PHP under Windows installation

Source: Internet
Author: User
Tags download redis phpinfo redis version vars

I. Pre-installation must read

Windows 64-bit operating system

Redis installation Package (version 3.0.5, as of 2017-05-29, the latest Redis version is 3.2.9)

Precautions:

1. Under window If you still need to install the Redis extension for PHP, then installing the latest version of Redis may not have a corresponding Php_redis. DLL;

2. The online installation of Redis and PHP extensions for Windows is mostly redis2.x version, which may not be applicable for the installation of high version;

3. At first I installed the latest version of redis3.2.9, in the installation of Php_redis development dumbfounded, Php_redis.dll did not find redis3.2 version, at least I spent a long time also did not find, tat!

Take a look at the 2017-05-29, downloadable version of Php_redis.dll, website link https://pecl.php.net/package/redis


Take a look at the version of Redis under the cutoff 2017-05-29,windows, git address https://github.com/MSOpenTech/redis/releases

See, Windows has redis3.2 version, but not good to find redis3.2 corresponding Php_redis.dll, so it is recommended that you choose the Redis version should pay attention to the corresponding Php_redis expansion can also be found!

Two. Installing Redis

1. Download Redis compression pack, githttps://github.com/msopentech/redis/releases

Here I choose 3.0.5 version, select Zip download


2. After downloading, unzip to Redis folder, the following is the extracted files, the installation is complete


Redis-cli.exe # Client
Redis-server.exe # Server
REDIS.WINDOWS.CONF # configuration file

3.redis Test

Windows run (shortcut key: Windows key +r), enter "cmd" command, enter the DOC operating system window;

Accessing the Redis installation directory using commands

[OBJC]View PlainCopy
    1. Redis-server redis. Windows. conf

Start Redis Service, this window does not need to close, close the window to stop the Redis service, start successfully such as:


Open a new Doc window, go to the installation directory to execute the client startup command "REDIS-CLI" or simply double-click Redis-cli.exe to test the command, create and get the name value Leesin data:

Three. Installing the Redis Extension for PHP

1. Download Php_redis.dll,https://pecl.php.net/package/redis

I chose version 3.0.0, which corresponds to the Redis installation version 3.0

Select the corresponding download in the newly opened window and view the Phpinfo information first.


So here I choose the 64-bit NTS version of the download

2. Locate the PHP installation directory and put the two files in the downloaded package into the Ext folder.

3. Modify PHP.ini Add

extension=php_redis.dll

Open Redis Extension, save and restart Nginx or Apache server

4. Verify that Redis expansion is turned on

Review the Phpinfo information again and search for Redis, which means it is open successfully.


5.php Connect and test the Redis database

New test.php

[PHP]View PlainCopy
    1. <?php
    2. $redis = new Redis ();
    3. $redis->connect (' 127.0.0.1 ', 6379);
    4. $redis->set (' name ',' leesin ');
    5. echo $redis->get (' name ');
    6. ?>

Visit test.php

Output Leesin

At this point, you are all done with Redis and PHP expansion installation under Windows!

Redis development tutorial for Redis and PHP under Windows installation

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.