php 如何在 WAMP 中启用内存缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3016656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:25:40  来源:igfitidea点击:

How to enable memcache in WAMP

phpwamp

提问by Bharanikumar

How to install memcache in WAMP?

如何在 WAMP 中安装内存缓存?

I don't find any php_memche in php.ini.

我在php.ini.

What do I do now?

现在我该怎么做?

@Ryan

@瑞安

thanks for your step, now memcache enabled in WAMP, i have cross checked in the PHPINFO as well. memcache is displaying.

感谢您的步骤,现在在 WAMP 中启用了 memcache,我也在 PHPINFO 中进行了交叉检查。内存缓存正在显示。

i have tried below example memcache sample. but throwing error.

我在下面的示例 memcache 示例中尝试过。但抛出错误。

<?php

$memcache = new Memcache;
$memcache->connect('localhost:8085', 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);

?>

Getting below notice error.

低于通知错误。

( ! ) Notice: Memcache::getversion() [memcache.getversion]: Server localhost:8085 (tcp 11211) failed with: Malformed version string (0) in C:\wamp\www\memcache\sample.php on line 7

What i missed...

我错过了什么...

回答by Ryan Charmley

Here are the steps that worked for me:

以下是对我有用的步骤:

Needed Files

所需文件

Steps

脚步

  1. Copy MSVCP71.DLL, msvcr71.dllto C:\windows\sysWOW64
  2. Copy memcached.exeinto C:\memcached
  3. Click Windows-Key
  4. Type: CMD
  5. press: Ctrl-Shift-Enter
  6. Choose yes
  7. type: C:\memcached\memcached.exe -d install
  8. type: C:\memcached\memcached.exe -d start
  9. Copy php_memcache.dllto C:\wamp\bin\php\php5.3.4\ext
  10. Restart Apache using Wamp controls
  11. Enable WAMP -> PHP -> PHP Extensions -> php_memcache
  1. 复制MSVCP71.DLLmsvcr71.dllC:\windows\sysWOW64
  2. 复制memcached.exeC:\memcached
  3. 单击 Windows 键
  4. 类型:CMD
  5. 按:Ctrl-Shift-Enter
  6. 选择 yes
  7. 类型: C:\memcached\memcached.exe -d install
  8. 类型: C:\memcached\memcached.exe -d start
  9. 复制php_memcache.dllC:\wamp\bin\php\php5.3.4\ext
  10. 使用 Wamp 控件重新启动 Apache
  11. 启用 WAMP -> PHP -> PHP 扩展 -> php_memcache

回答by Beachhouse

If you are running 64 bit WAMP:

如果您运行的是 64 位 WAMP:

The common service and extensions will not work for you.

公共服务和扩展对您不起作用。

Install the 64 bit memcached service:

安装 64 位 memcached 服务:

http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip

http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip

And one of these php extensions (to match your php version):

以及这些 php 扩展之一(以匹配您的 php 版本):

Php 5.3: http://www.mediafire.com/download.php?o60feet9sw71six

PHP 5.3:http: //www.mediafire.com/download.php?o60feet9sw71six

Php 5.4: http://www.mediafire.com/download.php?8d3vd26z3fg6bf1

PHP 5.4:http: //www.mediafire.com/download.php?8d3vd26z3fg6bf1

32bit version for Php 5.4: http://windows.php.net/downloads/pecl/releases/memcache/3.0.6/php_memcache-3.0.6-5.4-ts-vc9-x86.zip

Php 5.4 的 32 位版本:http: //windows.php.net/downloads/pecl/releases/memcache/3.0.6/php_memcache-3.0.6-5.4-ts-vc9-x86.zip

回答by Idan Magled

I was stuck on this for a while so I decided to write my answer:

我被困在这个问题上一段时间,所以我决定写下我的答案:

Step 1: download the right package that compatible with your PHP version and your wamp version (32bit or 64 bit) from this site:

第 1 步:从该站点下载与您的 PHP 版本和 wamp 版本(32 位或 64 位)兼容的正确软件包:

Link for download site

下载站点的链接

I suggest you download the "Thread Safe" one.

我建议您下载“线程安全”一个。

Step 2: After you downloaded the package, you need to copy the php_memcache.dllin to your extensions folder at: C:\wamp\bin\php\{YOUR PHP VERSION}\ext

第 2 步:下载软件包后,您需要将其复制php_memcache.dll到您的扩展文件夹中:C:\wamp\bin\php\{YOUR PHP VERSION}\ext

Step 3: Add the extensions value to your php.ini file, to do this in the right place just search for another extension that is already installed like: extension=php_bz2.dlland just copy paste it at the end of this sections (after all the "extension=")

第 3 步:将 extensions 值添加到您的php.ini file,要在正确的位置执行此操作,只需搜索已安装的另一个扩展,例如:extension=php_bz2.dll并将其复制粘贴到本节的末尾(毕竟是“extension=”)

extension=php_memcache.dll

扩展名=php_memcache.dll

Step 4: close and open up your WAMP (not restarting - close and open) and you done.

第 4 步:关闭并打开您的 WAMP(不重新启动 - 关闭并打开),您就完成了。

If you are having trouble now - just open the error log file (in the root directory) and check what is the error that you get there.

如果您现在遇到问题 - 只需打开错误日志文件(在根目录中)并检查您遇到的错误是什么。

My error was that my WAMP was a 32 bit, and i have downloaded 64 bit memcache

我的错误是我的 WAMP 是 32 位的,而我已经下载了 64 位的内存缓存

This solve my problem, hope its helped.

这解决了我的问题,希望它有所帮助。

回答by user1361389

to everyone having problems installing memcache for wamp here's how it worked for me.

对于在为 wamp 安装 memcache 时遇到问题的每个人,这对我来说是如何工作的。

  1. make sure you check you're phpinfo and look for "Compiler" mine shows MSVC9 (Visual C++ 2008) this is so you know if you download the dll for vc9 or vc6. also look for "Thread Safety" on phpinfo it shows enabled then you need to download the dll file that contains TS if disabled then you download the dll with the words NTS.
  1. 确保你检查你是 phpinfo 并寻找“编译器”我的显示 MSVC9 (Visual C++ 2008) 这是这样你就知道你是否下载了 vc9 或 vc6 的 dll。还要在 phpinfo 上查找“线程安全”,它显示已启用,然后您需要下载包含 TS 的 dll 文件,如果已禁用,则下载带有 NTS 字样的 dll。

below is where you can find the dll's for the diffent php versions make sure the version you download matches you're version:

下面是您可以找到不同 php 版本的 dll 的地方,确保您下载的版本与您的版本匹配:

Make sure also you have 32 bit or 64 bit and you download it correctly

确保您也有 32 位或 64 位并正确下载

then extract the files into your windows/system32 if you're windows is 32 bit or the system folder for 64 bit on you're windows.

然后将文件解压缩到你的 windows/system32 如果你是 32 位的 windows 或者你是 windows 上的 64 位的系统文件夹。

Also extract to you're wamp/bin/apache/bin and wamp/bin/you're_php_version/ext and also memcache.exe extract to this folder make sure you use memcached for 32 or 64 bit according to you're system.

还解压到你的 wamp/bin/apache/bin 和 wamp/bin/you're_php_version/ext 以及 memcache.exe 解压到这个文件夹,确保你根据你的系统使用 32 位或 64 位的 memcached。

Once you finish this then you run the you're windows command prompt as administrator then browse to the location of you're executable memcache and do the following:

完成此操作后,以管理员身份运行 Windows 命令提示符,然后浏览到可执行内存缓存的位置并执行以下操作:

step 1: memcache.exe -d install step 2: memcache.exe -d start

第 1 步:memcache.exe -d 安装 第 2 步:memcache.exe -d 启动

then on you're wampserver open the tray menu and go to the php menu and click php.ini make sure you add on you're extensions in case not listed there: extension=php_memcache.dll

然后在你的 wampserver 上打开托盘菜单并转到 php 菜单并单击 php.ini 确保你添加了你的扩展,以防那里没有列出:extension=php_memcache.dll

restart you're wampserver and go to you're phpinfo and look for memcache if you see it then it's installed.

重新启动您是 wampserver 并转到您是 phpinfo 并查找 memcache,如果您看到它,则它已安装。

hope it helps

希望能帮助到你

happy new year to all!

祝大家新年快乐!

回答by Pekka

Memcache is a PECL extension and not bundled with PHP. Start with the manual pagefor installation instructions.

Memcache 是一个 PECL 扩展,不与 PHP 捆绑在一起。从安装说明的手册页开始。

回答by rowmoin

  1. Download memcache not memcached if you used windows.Download your php version wise (download link:https://pecl.php.net/package/memcache/3.0.8/windows)
  2. Copy php_memcache.dll to C:\wamp\bin\php\php5.3.4\ext
  3. Restart Apache using Wamp controls
  4. Enable WAMP -> PHP -> PHP Extensions -> php_memcache
  1. 如果您使用 Windows,请下载 memcache 而不是 memcached。明智地下载您的 php 版本(下载链接:https: //pecl.php.net/package/memcache/3.0.8/windows
  2. 将 php_memcache.dll 复制到 C:\wamp\bin\php\php5.3.4\ext
  3. 使用 Wamp 控件重新启动 Apache
  4. 启用 WAMP -> PHP -> PHP 扩展 -> php_memcache

回答by Pranav MS

Memcache is a PECL extension and not bundled with PHP.

Memcache 是一个 PECL 扩展,不与 PHP 捆绑

This PECL extension is not bundled with PHP. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/memcache.

此 PECL 扩展未与PHP捆绑。有关安装此 PECL 扩展的信息可以在标题为“安装 PECL 扩展”的手册章节中找到。其他信息,如新版本、下载、源文件、维护者信息和变更日志,可以在这里找到:http://pecl.php.net/package/memcache 。

Note:
It's possible to disable memcache session handler support. 
The 'pecl install' option prompts for this (default is enabled) 
however when compiling statically into 
PHP the --disable-memcache-session configure option may be used.

It is very important to note when reading the information supplied by others on this page that there are two distinctmemcache PHP implementations for the service "memcached".

在阅读本页其他人提供的信息时,请务必注意,服务“memcached”有两种不同的memcache PHP 实现。

1) pecl-memcache
2) pecl-memcached

This page is for the first, pecl-memcache.

这个页面是第一个,pecl-memcache。

If you are looking for pecl-memcached information, visit here:

如果您正在寻找 pecl-memcached 信息,请访问此处:

http://www.php.net/manual/en/book.memcached.php

http://www.php.net/manual/en/book.memcached.php

回答by Gabe Hiemstra

Because my edit got rejected, here is what worked for me, as a supplement, after installing memcache on windows:

因为我的编辑被拒绝了,这是在 Windows 上安装 memcache 后对我有用的补充:

Manually add the memcache configuration to the php.ini. NOTE: there might be two different php.ini's installed on your system. For me, modifying the one located in wamp64/bin/apache is the only one that worked:

手动在 php.ini 中添加 memcache 配置。注意:您的系统上可能安装了两个不同的 php.ini。对我来说,修改 wamp64/bin/apache 中的那个是唯一有效的:

extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211

You may need to add the extension to the extension block;

您可能需要将扩展​​添加到扩展块;

Inspired from this thread.

灵感来自这个线程