Installation Guide for Redis and PHP Redis Extensions on Windows Systems
Article Description:
Redis latest version download link: https:\\www.github.com\dmajkic\redis\downloads. Please select the appropriate bit size package according to your machine system to download, and copy it to a customized folder (e.g. “C:\redis ”) for subsequent processing.
Start a command prompt window, enter the “C:\redis” directory with the “cd” command and execute “redis-server.exe redis.conf and execute ”redis-server.exe redis.conf". For convenience, it is recommended to add the path to Redis to the system environment variable to minimize the need to manually enter the path.
Next start a new command prompt window, keeping the first one open to access the server side at any time.
Run the command “redis-cli.exe -h 127.0.0.1 -p 6379” in this window.
Create a key-value pair named “myKey“, enter the command “SET myKey abc” and then enter.
To read the key-value pair, type “GET myKey” and enter.
So far, you have successfully setup and fetched key-value pairs in Redis from the command line. Now let's try to do the same in PHP code.
Below is a sample PHP code:
<?php
//Instantiating Redis Objects
$redis = new Redis();
//Connect to the Redis service (this refers to the server kernel, not the server as a whole)
$redis->pconnect(‘127.0.0.1’, ‘6379’);
//Set key-value pairs with specified names and values
$redis->set($key, $value);
//Query the previously set key-value pairs
echo $redis->get($key); echo $redis->get($key);
//Disconnect from Redis service
$redis->close();
? >
Following these steps, we have completed the integration of Redis in PHP. Please note that the above code may display an error during execution. This is usually caused by not having the correct Redis extension installed.
Redis is a powerful open-source database program , written in ANSI C , supporting network storage and persistent logging mode of operation . At the same time, it also provides API interface support for many mainstream programming languages, such as Java, C/C++, C#, PHP,JavaScript, Perl, Object-C,pythonThis document describes how to install and configure the Redis service on Windows and how to use the Redis network database service with PHP. This document describes how to install and configure the Redis service on a Windows operating system and how to use the Redis web database service in PHP.
Please first check the current version of your PHP environment in order to establish the version of the required extension file. Afterwards, refer to the following two websites for download operations:
1. http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/
2. http://windows.php.net/downloads/pecl/releases/igbinary/1.2.1/
Unzip the downloaded rar file separately and copy the python_igbinary.dll and php_redis.dll contained in it to the corresponding ext directory.
Next you need to configure the php.ini file. Add two statements to this file:
extension = php_igbinary.dll
extension = phpi_redis.dll
In particular, make sure that the phrase “extension = php_igbinary.dll” comes before “extension = php_redis.dll”, otherwise the extension will not be enabled properly. will not be enabled properly.
After making these changes, restart your web server. If the restart is successful, you can find information about the redis extension on the phpinfo page, which confirms that the redis extension was installed successfully.
Running the piece of code that was initially tested will show the expected results.
It is important to note that under no circumstances should you close the black window, your computer is playing a server-side role.
- Can free downloads or VIP member-only resources be commercialized directly?
- The resources on this site are collected and organized through the network, for personal research and study purposes only. The copyright belongs to the legal owner of the software and program code, users should verify the copyright and legality of the resources, prohibited for commercial use, illegal activities or any violation of national laws and regulations.
- Disclaimer of liability for program or code bugs, compatibility issues or functional defects, etc.
- As the resources on this site are collected and organized through the network, not the site's original, it can not fully guarantee its functionality or code compatibility. Users need to verify whether the resources meet the needs of their own, due to the following circumstances lead to losses, this site does not assume any responsibility:
Programs, source code and other computer software resources may contain code vulnerabilities (bugs), compatibility issues or functional defects left by the developer. This site does not provide free repair services for such technical defects, users need to bear the risk of debugging, modification or abandonment of the use.




