Home > Backend Development > PHP Tutorial > Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

不言
Release: 2023-03-23 13:50:01
Original
1988 people have browsed it

The content of this article is to install Memcached and install the Memcache extension of PHP 7.0.22 under Windows 10 64. Now I share it with you. Friends in need can refer to it


1. I have written a blog before under PHP 5.6.27: http://www.shuijingwanwq.com/2017/09/11/1892/, this time it is under PHP 7.0.22, as shown in the figure 1

之前写过一篇在 PHP 5.6.27 下的博客:http://www.shuijingwanwq.com/2017/09/11/1892/ ,此次是 PHP 7.0.22 下的

##Figure 1

2. To uninstall memcached, you can use the following command: as shown in Figure 2

schtasks /delete /tn memcached

卸载 memcached

Figure 2

3. Delete the directory: C:\memcached-1.4.5, as shown in Figure 3

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

Figure 3

4. Open the URL: https://github.com/nono303/memcached/tree/master/cygwin/x64, download: cygevent-2-0-5.dll, cygwin1.dll , memcached-1.5.1.exe, as shown in Figure 4

打开网址:https://github.com/nono303/memcached/tree/master/cygwin/x64 ,下载:cygevent-2-0-5.dll、cygwin1.dll、memcached-1.5.1.exe

Figure 4

5. After successful download, copy to: C:\memcached-1.5 .1, as shown in Figure 5

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

Figure 5

6. Run Windows PowerShell as an administrator, as shown in Figure 6

以管理员身份运行 Windows PowerShell

Figure 6

#7. Execute the following command to add memcached to the task schedule: as shown in Figure 7

schtasks /create /sc onstart /tn memcached /tr “'C :\memcached-1.5.1\memcached-1.5.1.exe' -m 512”

执行以下命令将 memcached 添加来任务计划表中

Figure 7

8. Open the URL: https: //github.com/nono303/PHP7-memcache-dll, select vc14, as shown in Figure 8

打开网址:https://github.com/nono303/PHP7-memcache-dll ,选择vc14##Figure 8

9. View phpinfo, compiler It is MSVC14 and thread-safe, as shown in Figure 9

查看 phpinfo,编译器为MSVC14,且线程安全Figure 9

10. Open the URL: https://github.com/nono303/PHP7- memcache-dll/tree/master/vc14/x64/ts, download: php-7.0.x_memcache.dll, as shown in Figure 10

打开网址:https://github.com/nono303/PHP7-memcache-dll/tree/master/vc14/x64/ts ,下载:php-7.0.x_memcache.dllFigure 10

11. Copy php-7.0.x_memcache.dll to: C:\php-7.0.22\ext\php_memcache.dll, as shown in Figure 11

##Figure 11将 php-7.0.x_memcache.dll 复制至:C:\php-7.0.22\ext\php_memcache.dll

12. Add the following lines in C:\php-7.0.22\php.ini to enable the memcache extension, as shown in Figure 12

extension=php_memcache.dll

在 C:\php-7.0.22\php.ini 中添加以下行以启用memcache扩展

Figure 12

13. Check phpinfo, memcache already exists, as shown in Figure 13

查看 phpinfo,memcache已经存在

Figure 13

14. Create a new test program: memcached.php, as shown in Figure 14

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

##Figure 14


15. After restarting the machine, run the test program and an error message is reported: Notice: Memcache::connect(): Server localhost (tcp 11211, udp 0) failed with:, as shown in Figure 15

在重启机器后,运行测试程序,报错:Notice: Memcache::connect(): Server localhost (tcp 11211, udp 0) failed with:

Figure 15

16. Open the task scheduler, edit the trigger of memcached, and change it from startup to login, as shown in Figure 16

打开任务计划程序,编辑 memcached 的触发器,从启动时修改为登录时

Figure 16

17. At this time, the trigger of memcached is: when any user logs in, as shown in Figure 17

此时,memcached 的触发器已经为:当任何用户登录时

Figure 17

18. After restarting the machine, the C:\memcached-1.5.1\memcached-1.5.1.exe command line window is displayed, indicating that the planned task was successfully executed, as shown in Figure 18

在重启机器后,显示:C:\memcached-1.5.1\memcached-1.5.1.exe 命令行窗口,说明计划任务成功执行

Figure 18

19. Run the test program, normal, as shown in Figure 19

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

Figure 19

20. It is hoped that when the system starts, the command line window will not be displayed and the user or group will be changed, as shown in Figure 20

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22

Figure 20

21. In the pop-up Select User or Group window, we select Advanced – Find Now – select SYSTEM and click OK, as shown in Figure 21

在弹出的选择用户或组窗口中,我们选择高级 - 立即查找 - 选择 SYSTEM,点击确定

##Figure 21

22. When running the task, please use the following user account, which is: SYSTEM, as shown in Figure 22

Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22##Figure 22

23. Restart the machine After that, the C:\memcached-1.5.1\memcached-1.5.1.exe command line window is not displayed, and the test program is run, and it is normal, as shown in Figure 23

在重启机器后,未显示:C:\memcached-1.5.1\memcached-1.5.1.exe 命令行窗口,且Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22 Related recommendations:

Compile php7.2 under windows and extend judy

php configuration and instructions for extending redis under windows

How to build Apache PHP environment under Windows

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21


<?php
 
$memcache = new Memcache;
$memcache->connect(&#39;localhost&#39;, 11211) or die ("Could not connect");
 
$version = $memcache->getVersion();
echo "Server&#39;s version: ".$version."<br/>\n";
 
$tmp_object = new stdClass;
$tmp_object->str_attr = &#39;test&#39;;
$tmp_object->int_attr = 123;
 
$memcache->set(&#39;key&#39;, $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
 
$get_result = $memcache->get(&#39;key&#39;);
echo "Data from the cache:<br/>\n";
 
var_dump($get_result);
 
?>
Copy after login


The above is the detailed content of Installing Memcached under Windows 10 64 and installing the Memcache extension for PHP 7.0.22. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template