摘要:环境下安装下载安装包解压到盘任意位置以管理员身份运行,否则安装失败执行命令没有报错说明我们已经安装成功下载我的是的版本所以下载位版本将扩展放入扩展文件夹中在中添加然后重启注意文件夹中的是用于浏览器访问文件夹中的是适用于命令行运行脚本测试代码
下载 memcache 安装包 :http://pan.baidu.com/s/1pLcjTzl
解压到d盘任意位置 , cmd(以管理员身份运行,否则安装失败) 执行命令
没有报错说明我们已经安装成功
下载 php_memcache.dll : https://pecl.php.net/package/memcache/3.0.8/windows
我的是5.6的版本 所以下载 64位 TS版本
将dll扩展放入php扩展文件夹中
在php.ini 中添加 extension=php_memcache.dll
然后重启wampserver
注意:apache文件夹中的php.ini 是用于浏览器访问 php文件夹中的php.ini 是适用于命令行运行php脚本
php测试代码 (我的是命令行测试)
安装环境说明:
操作系统:Centos 6.5 -64bit
安装路径:/usr/local/memcached
yum install libevent libevent-devel
[root@localhost home]# wget http://memcached.org/files/memcached-1.4.25.tar.gz
tar zxvf memcached-1.4.25.tar.gz
打开文件夹 指定安装路径 并编译
cd memcached-1.4.25
./configure --prefix=/usr/local/memcached
make && make install
下载php memcache 扩展 tgz包
[root@localhost home]# wget https://pecl.php.net/get/memcache-3.0.8.tgz
[root@localhost home]# tar zxf memcache-3.0.8.tgz
[root@localhost home]# cd memcache-3.0.8
[root@localhost memcache-3.0.8]# /usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
# 安装成功后会输出这个地址,这是php扩展模块文件夹 /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
#php.ini 中的 extension_dir =” ./” #修改为extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/” (若已经修改过请忽略) #添加 extension=memcache.so #重启 php-fpm /etc/init.d/php-fpm restart
下载libevent tgz包 并安装
官网:http://libevent.org/
[root@localhost home]# tar zxf libevent-2.0.21-stable.tar.gz
[root@localhost home]# cd libevent-2.0.21-stable
[root@localhost home]# ./configure --prefix=/usr/local/libevent/
[root@localhost libevent-2.0.21-stable]# make && make install
重新编译安装memcached服务,并配置libevent
[root@localhost home]# cd memcached-1.4.25
[root@localhost memcached-1.4.25]# ./configure --prefix=/usr/local/memcache/ --with-libevent=/usr/local/libevent/
[root@localhost memcached-1.4.25]# make && make install
下载 libmemcached tgz包 并编译安装
安装SASL相关环境 yum install cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib 官网:http://libmemcached.org/libMemcached.html [root@localhost home]# wget https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz [root@localhost home]# tar zxf libmemcached-1.0.18.tar.gz [root@localhost home]# cd libmemcached-1.0.18 [root@localhost libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached --with-memcached --enable-sasl [root@localhost libmemcached-1.0.18] make [root@localhost libmemcached-1.0.18] make install
下载php memcached 扩展 tgz包
[root@localhost home]# wget https://pecl.php.net/get/memcached-2.2.0.tgz
[root@localhost home]# tar zxf memcached-2.2.0.tgz
[root@localhost home]# cd memcached-2.2.0
[root@localhost memcached-2.2.0]# /usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
--with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意这个参数)
如果提示下面错误信息 说明我们要安装 libsasl2-dev
yum直接搜索是没有对应的package的 我们用笨方法 [root@localhost home]# yum search sasl | grep dev [root@localhost home]# yum install cyrus-sasl-devel
继续编译
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl(注意这个参数) make make install
# 安装成功后会输出这个地址,这是php扩展模块文件夹
/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
#php.ini 中的 extension_dir =” ./” #修改为extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/” (若已经修改过请忽略) #添加 extension=memcached.so #重启 php-fpm /etc/init.d/php-fpm restart
[root@localhost init.d]# touch memcached [root@localhost init.d]# chmod 777 memcached
复制粘贴以下内容于 redis文件 保存退出
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# Source function library - for other linux
. /etc/rc.d/init.d/functions
# Source function library - for suse linux
#. /lib/lsb/init-functions
ip="127.0.0.1" # 绑定侦听的IP地址
port="11211" # 服务端口
username="root" # 运行程序的用户身份
max_memory=64 # default: 64M | 最大使用内存
max_connection=1024 # default: 1024 | 最大同时连接数
if [ -f /etc/sysconfig/memcached ];then
. /etc/sysconfig/memcached
fi
# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
exit 0
fi
RETVAL=0
prog="memcached"
pidfile=/tmp/memcached.pid
basedir=/usr/local/memcached
cmd=${basedir}/bin/memcached
start () {
echo -n $"Starting service:$prog "
chown $username $basedir
$cmd -d -p $port -u $username -m $max_memory -c $max_connection -P $pidfile $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
return $retval
}
stop() {
echo -n $"Stopping service: $prog "
current_user=$(whoami)
pidlist=$(ps -ef | grep $current_user | grep memcached | grep -v grep | awk "{print $2}")
for pid in $pidlist ; do
kill -9 $pid
if [ $? -ne 0 ]; then
return 1
fi
done
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/memcached
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/memcached ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $?
配置开启自启动
chkconfig --add memcached
增加开启启动设置启动级别
chkconfig --level 2345 memcached on
测试启动,停止,重启memcached
# 服务启动,停止service memcached start service memcached stop
# init.d目录启动,停止/etc/init.d/memcached start/etc/init.d/memcached stop
# 打开防火墙规则vim /etc/sysconfig/iptables # 增加内容 -A INPUT -p tcp -m tcp --dport 11211 -j ACCEPT # 重启火墙规则立即生效service iptables restart
$memcached = new Memcached();
$memcached->addServer("192.168.206.128",11211);
$memcached->set("key","TK");
echo $memcached->get("key"); // TK
$memcache = new Memcache;
$memcache->connect("127.0.0.1", 11211);
$memcache ->set("key","TK");
echo $memcache ->get("key"); // TK
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/61683.html
摘要:环境下安装下载安装包解压到盘任意位置以管理员身份运行,否则安装失败执行命令没有报错说明我们已经安装成功下载我的是的版本所以下载位版本将扩展放入扩展文件夹中在中添加然后重启注意文件夹中的是用于浏览器访问文件夹中的是适用于命令行运行脚本测试代码 windows 64bit 环境下安装 下载 memcache 安装包 :http://pan.baidu.com/s/1pLcjTzl 解压到...
摘要:对于来说,在主机操作系统上运行是绝对必要的。在和中,从主机操作系统中运行可以出现系统通知。你仍然可以在或的虚拟机中成功地运行,但在发出通知时将收到警告错误仅从你的主机操作系统运行。 原文地址: Laravel 5.1 Beauty - Required Software and Components 怎样安装开发 Laravel 5.1 必要的软件: VirtualBox 和 Vagr...
阅读 1001·2023-04-25 19:28
阅读 1881·2021-09-10 10:51
阅读 2629·2019-08-30 15:55
阅读 3695·2019-08-26 13:55
阅读 3287·2019-08-26 13:24
阅读 3577·2019-08-26 11:46
阅读 2977·2019-08-23 17:10
阅读 1665·2019-08-23 16:57