(转发)centos,redhat 系统为php安装memcached扩展

转自:http://www.itnose.net/detail/6111623.html

1. 通过yum安装
yum -y install memcached

#安装完成后执行:

memcached -h

#出现memcached帮助信息说明安装成功

2. 加入启动服务

chkconfig --level 2345 memcached on

3. 配置Memcached

vim /etc/sysconfig/memcached

#文件中内容如下,按需要修改:

PORT="11211" #端口

USER="root" #用户名

MAXCONN="1024" #最大连接数

CACHESIZE="64" #内存大小

OPTIONS="" #附加参数

4. 安装libmemached

wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz

tar -zxvf libmemcached-1.0.16.tar.gz

cd libmemcached-1.0.16

./configure -prefix=/usr/local/libmemcached -with-memcached

make && make install

报错:g++: command not found的解决

yum -y install gcc+ gcc-c++

make clean后,重新执行:make && make install

5. 安装php-devel

yum install php-devel

6. 安装PHP Memcached扩展

wget http://pecl.php.net/get/memcached-2.1.0.tgz

tar -zxvf memcached-2.1.0.tgz

cd memcached-2.1.0

/usr/local/php/bin/phpize

./configure -enable-memcached
-with-php-config=/usr/local/php/bin/php-config -with-zlib-dir
-with-libmemcached-dir=/usr/local/libmemcached
-prefix=/usr/local/phpmemcached

make && make install

报错:memcache support requires ZLIB解决办法

yum install zlib-devel

记录下安装成功后的提示,类似于:

Installing shared extensions: /usr/lib/php/modules/

7.增加扩展extension配置文件

vi /etc/php.d/memcached.ini

增加1行

extension=memcached.so

最后验证一下是否安装完成

php -m|grep memcached

应该会显示memcached

8.重启nginx/amapche,重启php-fpm,使用phpinfo()查看memcached模块是否安装成功。

****************************************************************************************

memcached能启动但无法用php连接的问题(浏览器打开包含memcached的页面,firebug报500错误)
1.SELINUX=enforcing 改为 SELINUX=disabled
2.在终端尝试使用:telnet localhost 11211或者telnet 127.0.0.1 11211来连接到memcached的服务器
如果提示bash: telnet: command not found
执行:yum install telnet -y,再次回到浏览器尝试打开。

测试脚本:

<?php
$m = new Memcached;
$m->addServer(‘127.0.0.1‘, 11211);
$m->set(‘foo‘, 200);
var_dump($m->get(‘foo‘));
?>
时间: 2024-12-24 14:27:39

(转发)centos,redhat 系统为php安装memcached扩展的相关文章

centos系统为php安装memcached扩展

1. 通过yum安装 yum -y install memcached #安装完成后执行: memcached -h #出现memcached帮助信息说明安装成功 2. 加入启动服务 chkconfig --level 2345 memcached on 3. 配置Memcached vim /etc/sysconfig/memcached #文件中内容如下,按需要修改: PORT="11211" #端口 USER="root" #用户名 MAXCONN="

安装memcached扩展

php扩展需要到一个专门的网站查找扩展包,这个网站就是http://pecl.php.net/  这是一个php扩展包的网站,可以在这个网站上找到php关于memcached的扩展包,搜索memcached以后,我下载了memcached-2.2.0.tgz,接下来我们正式进入安装memcached扩展的过程(好像已经说了很多废话了--不管了,反正也没人看我的博客) 先下载libmemcached: wget  https://launchpad.net/libmemcached/1.0/1.0

linux系统下php安装mbstring扩展的二种方法

.执行 复制代码代码如下: yum install php-mbstring 2. 修改php.ini (这一步非常重要, 部分lxadmin版本无法自动修改) 复制代码代码如下: echo ‘extension=mbstring.so' >>/etc/php.ini #更具php安装目录而定 3. 重启web service 如果是apache: service httpd restart 方法二:php 5.36安装目录:/usr/local/php 复制代码代码如下: #cd /usr/

mac安装memcached扩展

由于mac本身装有apache和php,所以不需要安装这两个软件.目前只需要安装memcached扩展.这也是整个环境搭建比较复杂的地方. 经过尝试,只有macport方式安装的memcached能正常安装成功. 一.安装macports 通过http://www.macports.org/install.php地址寻找和机器匹配的版本,下载,安装 二.安装memcached. 注意:如果没有port命令,可重启一下terminal 通过刚才安装的macport来安装memcached扩展,命令

CentOS下使用yum快速安装memcached

参考文章: 1. http://www.free521.com/tutorials/vps-tutorials/4360.html 2. http://snowolf.iteye.com/blog/1447348 3. memcache 连接错误  http://chenwei.me/p/70.html ------------------------------------------------------------------------------------------ 1. 查找M

centos php 安装memcached 扩展 支持sasl

1.安装sasl yum install cyrus-sasl-lib.x86_64 yum install cyrus-sasl-devel.x86_64 2.下载libmemcached wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz 3,编译安装 tar zxvf libmemcached-1.0.16.tar.gz cd libmemcached-1.0.16

linux php安装memcached扩展

memcached的安装包括:1.服务端的安装:2.客户端的安装 一.服务器端安装 方法一: memcached 依赖于libevent 库,因此我们需要先安装libevent. 假设将源码放在/usr/local/src 1 cd /usr/local/src 2 wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz 3 ta

安装memcached扩展 验证过了可行

. 安装libmemached 复制代码 代码如下: wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gztar -zxvf libmemcached-1.0.16.tar.gzcd libmemcached-1.0.16./configure -prefix=/usr/local/libmemcached -with-memcachedmake && make ins

centos7 安装memcached扩展

1,安装memcached yum -y install memcached /usr/bin/memcached -b -l 127.0.0.1 -p 11211 -m 150 -u root查看memcached是否在运行: [root@localhost /]# ps -ef | grep memcached //或 [root@localhost /]# pstree -p | grep memcached 如果能够看到存在memcached进程,那就说明我们的 memcached 服务