Installation of Redis under Windows 10 (based on WSL2 installation)
1. Redis officially does not have native installation packages under Windows. as shown in Figure 1
2. Reference:The project is no longer actively maintained. If you are looking for a Windows version of Redis, you may need to check Memurai. Please note that Microsoft does not officially recognize the product in any way. Decided to use memurai. as shown in Figure 2
3. After installing memurai-developer-v4.1.2.msi, restart the computer to make the environment variable take effect.
4. In the end, it was found that there was no effect, and c:\program files\memurai did not exist. Execute: C:\>msiExec /quiet/i memurai.msi , still no effect. Finally decided to give up.
PS C:\> msiexec /quiet /i memurai.msi PS C:\>
5. Check port 6379 is occupied again.
PS C:\> netstat -ano | findstr :6379 TCP 192.168.89.29:63792 3.231.104.211:443 Established 4920
6. Reference:Install or enable WSL2 . as shown in Figure 3
ps c:\> wsl --install Installing: Virtual Machine Platform The virtual machine platform is installed. Installing: Windows subsystem for Linux Windows subsystem for Linux is installed. Installing: Windows subsystem for Linux Windows subsystem for Linux is installed. Installing: Ubuntu Ubuntu is installed. The requested operation was successful. Changes will not take effect until the system is restarted. PS C:\>
7. Install redis, enter ubuntu, and install the latest stable version of redis, packages.redis.io from the official apt repository. Add the repository to the apt index, update it, and install it. as shown in Figure 4
root@desktop-h4mgqiu:~# curl -fssl https://packages.redis.io/gpg | sudo gpg --darmor -o /usr/share/keyrings/redis-archive-keyring.gpg root@desktop-h4mgqiu:~# echo "deb[signed-by=/usr/share/keyrings/redis-archive-keyring.gpg]https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list deb[signed-by=/usr/share/keyrings/redis-archive-keyring.gpg]https://packages.redis.io/deb Jammy Main root@desktop-h4mgqiu:~# sudo apt-get update get:1 https://packages.redis.io/deb Jammy InRelease[3821 B] get:2 https://packages.redis.io/deb jammy/main all packages[4502 B] get:3 https://packages.redis.io/deb Jammy/Main AMD64 Packages[21.2 kB] Hit:4 http://archive.ubuntu.com/Ubuntu Jammy InRelease get:5 http://security.ubuntu.com/ubuntu jammy-security inrelease[129 kB] get:6 http://archive.ubuntu.com/ubuntu jammy-updates inrelease[128 kB] get:7 http://security.ubuntu.com/ubuntu jammy-security/main amd64 packages[1673 kB] get:8 http://archive.ubuntu.com/ubuntu jammy-backports inrelease[127 kB] get:9 http://archive.ubuntu.com/ubuntu jammy/universe amd64 packages[14.1 MB] get:10 http://security.ubuntu.com/ubuntu jammy-security/main translation-en[279 kB] get:11 http://security.ubuntu.com/ubuntu jammy-security/main amd64 c-n-f metadata[13.0 kB] get:12 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 packages[2171 kB] get:13 http://security.ubuntu.com/ubuntu jammy-security/restricted translation-en[372 kB] get:14 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 c-n-f metadata[572 B] get:15 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 packages[886 kB] get:16 http://security.ubuntu.com/ubuntu jammy-security/universe translation-en[173 kB] get:17 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f metadata[18.9 kB] get:18 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 packages[37.2 kB] get:19 http://security.ubuntu.com/ubuntu jammy-security/multiverse translation-en[7588 B] get:20 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f metadata[228 B] get:21 http://archive.ubuntu.com/ubuntu jammy/universe translation-en[5652 kB] get:22 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f metadata[286 kB] get:23 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 packages[217 kB] get:24 http://archive.ubuntu.com/ubuntu jammy/multiverse translation-en[112 kB] get:25 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f metadata[8372 B] get:26 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 packages[1888 kB] Get:27 http://archive.ubuntu.com/ubuntu jammy-updates/main translation-en[337 kB] get:28 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 c-n-f metadata[17.7 kB] get:29 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 packages[2238 kB] get:30 http://archive.ubuntu.com/ubuntu jammy-updates/restricted translation-en[384 kB] get:31 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 c-n-f metadata[604 B] get:32 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 packages[1108 kB] get:33 http://archive.ubuntu.com/ubuntu jammy-updates/universe translation-en[258 kB] get:34 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f metadata[25.4 kB] get:35 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 packages[43.3 kB] Get:36 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse translation-en[10.8 kB] get:37 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 c-n-f metadata[444 B] get:38 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 packages[67.1 kB] get:39 http://archive.ubuntu.com/ubuntu jammy-backports/main translation-en[11.0 kB] get:40 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 c-n-f metadata[388 B] get:41 http://archive.ubuntu.com/ubuntu jammy-backports/restricted amd64 c-n-f metadata[116 B] get:42 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 packages[28.8 kB] get:43 http://archive.ubuntu.com/ubuntu jammy-backports/universe translation-en[16.5 kB] get:44 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f metadata[672 B] get:45 http://archive.ubuntu.com/ubuntu jammy-backports/multiverse amd64 c-n-f metadata[116 B] Fetched 32.8 MB in 19s (1686 KB/s) Reading package lists... done root@desktop-h4mgqiu:~# sudo apt-get install redis Reading package lists... done Building dependency tree... done Reading state information... done The following additional packages will be installed: redis-server redis-tools Suggested packages: ruby-redis The following new packages will be installed: redis-server redis-tools 0 upgraded, 3 newly installed, 0 to remove and 112 not upgraded. Need to get 1726 KB of Archives. After this operation, 9790 KB of additional disk space will be used. Do you want to continue?[Y/n]y get:1 https://packages.redis.io/deb jammy/main amd64 redis-tools amd64 6:7.2.5-1rl1~jammy1[1610 kB] get:2 https://packages.redis.io/deb jammy/main amd64 redis-server amd64 6:7.2.5-1rl1~jammy1[82.3 kB] get:3 https://packages.redis.io/deb jammy/main amd64 redis all 6:7.2.5-1rl1~jammy1[33.9 kB] Fetched 1726 KB in 4s (493 KB/s) Selecting previously unselected package redis-tools. (Reading database ... 24208 Files and Directories currently installed.) preparing to unpack .../redis-tools_6%3a7.2.5-1rl1~jammy1_amd64.deb ... unpacking redis-tools (6:7.2.5-1rl1~jammy1) ... Selecting previous unselected package redis-server. preparing to unpack .../redis-server_6%3a7.2.5-1rl1~jammy1_amd64.deb ... unpacking redis-server (6:7.2.5-1rl1~jammy1) ... Selecting previously unselected package redis. Preparing to unpack .../redis_6%3a7.2.5-1rl1~jammy1_all.deb ... unpacking redis (6:7.2.5-1rl1~jammy1) ... Setting up redis-tools (6:7.2.5-1rl1~jammy1) ... Setting up redis-server (6:7.2.5-1rl1~jammy1) ... Setting up Redis (6:7.2.5-1rl1~jammy1) ... Processing triggers for man-db (2.10.2-1) ... root@desktop-h4mgqiu:~#
8. Edit the configuration file of redis /etc/redis/redis.conf. To the Bind option (Bind), usually the default is binding to 127.0.0.1, and modify it to bind to all interfaces 0.0.0.0. as shown in Figure 5
9. Save and close the file. Then restart the redis service for changes to take effect:
sudo service redis-server restart
10. Run ip addr in the wsl terminal to find the ip address of wsl
root@desktop-h4mgqiu:~# ip addr 1: lo: <loopback,up,lower_up> MTU 65536 Qdisc noqueue state unknown group default qlen 1000 link/loopback 00:00:00:00:00 brd 00:00:00:00:00 Inet 127.0.0.1/8 Scope Host Lo VALID_LFT FOREVERRED_LFT FOREVER INET6 ::1/128 Scope Host VALID_LFT FOREVERRED_LFT FOREVER 2: eth0: <broadcast,multicast,up,lower_up> MTU 1500 QDisc MQ State Up Group Default Qlen 1000 Link/Ether 00:15:5d:7b:2d:f2 brd ff:ff:ff:ff:ff:ff INet 172.24.155.141/20 BRD 172.24.159.255 Scope Global eth0 VALID_LFT FOREVERRED_LFT FOREVER INET6 FE80::215:5DFF:FE7B:2DF2/64 SCOPE LINK VALID_LFT FOREVERRED_LFT FOREVER root@desktop-h4mgqiu:~#
11. Set the authentication password for the default user, otherwise you may not be able to access Redis from the external Windows host. Then restart the service. as shown in Figure 6
root@desktop-h4mgqiu:~# vi /etc/redis/redis.conf root@desktop-h4mgqiu:~# sudo service redis-server restart root@desktop-h4mgqiu:~#
12. Connect to Redis in WSL on Windows, the connection is successful. as shown in Figure 7






