在 Windows 10 64 下安装 Memcached和安装 PHP 7.0.22 的 Memcache 扩展

不言
不言 原创
2023-03-23 13:50:01 1490浏览

本篇文章的内容是在 Windows 10 64 下安装 Memcached和安装 PHP 7.0.22 的 Memcache 扩展 ,现在分享给大家,有需要的朋友可以参考一下


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

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

图1

2、卸载 memcached ,可以使用以下命令:,如图2
schtasks /delete /tn memcached

卸载 memcached

图2

3、删除目录:C:\memcached-1.4.5,如图3

删除目录:C:\memcached-1.4.5

图3

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

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

图4

5、下载成功后,复制至:C:\memcached-1.5.1,如图5

下载成功后,复制至:C:\memcached-1.5.1

图5

6、以管理员身份运行 Windows PowerShell,如图6

以管理员身份运行 Windows PowerShell

图6

7、执行以下命令将 memcached 添加来任务计划表中:,如图7
schtasks /create /sc onstart /tn memcached /tr “‘C:\memcached-1.5.1\memcached-1.5.1.exe’ -m 512”

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

图7

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

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

图8

9、查看 phpinfo,编译器为MSVC14,且线程安全,如图9

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

图9

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

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

图10

11、将 php-7.0.x_memcache.dll 复制至:C:\php-7.0.22\ext\php_memcache.dll,如图11

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

图11

12、在 C:\php-7.0.22\php.ini 中添加以下行以启用memcache扩展,如图12
extension=php_memcache.dll

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

图12

13、查看 phpinfo,memcache已经存在,如图13

查看 phpinfo,memcache已经存在

图13

14、新建测试程序:memcached.php,如图14

新建测试程序:memcached.php

图14


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('localhost', 11211) or die ("Could not connect");
 
$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";
 
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
 
$memcache->set('key', $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('key');
echo "Data from the cache:<br/>\n";
 
var_dump($get_result);
 
?>


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

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

图15

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

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

图16

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

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

图17

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

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

图18

19、运行测试程序,正常,如图19

运行测试程序,正常

图19

20、希望在系统启动时,不要显示命令行窗口,更改用户或组,如图20

希望在系统启动时,不要显示命令行窗口,更改用户或组

图20

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

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

图21

22、运行任务时,请使用下列用户帐户,已为:SYSTEM,如图22

运行任务时,请使用下列用户帐户,已为:SYSTEM

图22

23、在重启机器后,未显示:C:\memcached-1.5.1\memcached-1.5.1.exe 命令行窗口,且运行测试程序,正常,如图23

在重启机器后,未显示:C:\memcached-1.5.1\memcached-1.5.1.exe 命令行窗口,且运行测试程序,正常

相关推荐:

windows 下编译php7.2 极其扩展 judy

php 在 windows 下扩展redis 的配置与说明

Windows下 Apache PHP 环境搭建的方法

以上就是在 Windows 10 64 下安装 Memcached和安装 PHP 7.0.22 的 Memcache 扩展 的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。