windows中为php安装mongodb与memcache,mongodbmemcache
mangodb安装
1. 下载mongodb的安装文件,我安装的windows 64位的,下载地址如下:
https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.6-signed.msi
2. 新建一个mongodb文件夹在E盘(随便放,如E:\mongodb)
3. 将下载的安装文件解压,把解压的文件移动到E盘mongodb下
4. 建立mongodb数据存放目录E:\mongodb\data
5. 启动mongodb(简单启动不配置服务)
复制代码 代码如下:
E:\mongodb\bin\mongod.exe --dbpath E:\mongodb\data
可以看到如下信息:
说明安装启动成功了。
6.在浏览器中输入http://localhost:27017/,会出现下面信息,表明mongdb已经启动好了
复制代码 代码如下:
It looks like you are trying to access MongoDB over HTTP on the native driver port.
7、下载对应的mongodb php插件(不太好找,如果php是5.4-5.5版可用这个地址:http://pan.baidu.com/s/1sjJjsYh)并配置好。
8、在php中使用:
复制代码 代码如下:
try {
$mongo = new Mongo('localhost');
} catch(MongoConnectionException $e) {
var_dump($e);
}
$mongo_db = $mongo->selectDB('logdatastorage');
注:上面的代码是demo,不可在生产环境中使用。
memcache安装
1、64位下载
From:http://www.urielkatz.com/archive/detail/memcached-64-bit-windows/
下载:http://www.urielkatz.com/projects/memcached-win64/memcached-win64.zip
源码:http://www.urielkatz.com/projects/memcached-win64/memcached-src.rar
2、解压刚刚下载的压缩包,得到两个文件:memcached.exe(服务端主程序)、pthreadGC2.dll
3、以管理员权限运行命令提示符,定位到解压路径,安装Memcached服务,命令:
复制代码 代码如下:
memcached.exe -d install
4、执行 开始→管理工具→服务 打开Windows服务查看工具,找到memcached服务(没找到证明没有安装成功)
5、启动Memcached:
复制代码 代码如下:
memcached.exe -m 1024 -d start
-d为守护进程启动,不能指定端口 默认端口11211
-m为指定内存大小
6、配置Windows防火墙,为Memcached默认端口11211 添加入站规则(如果服务端和客户端都在本机,不需要这一步)
7、测试是否可以正常通讯,这里借助Telnet:
复制代码 代码如下:
telnet 127.0.0.1 11211
如果进入一个空白的doc屏,估计OK了。第一行命令输入是看不见的,所以我一般先敲一次回车,回返回一个Error,没关系,这是说明你输入的是一个无法识别的命令;
接着看下状态,键入stats然后回车:
8、下载对应的memcache php插件(如果php是5.5版可用这个地址:http://pan.baidu.com/s/1mgspf9e)并配置好。
9、在php中连接使用:
复制代码 代码如下:
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211);

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.