CentOS编译安装PHP的Memcached扩展

安装 Memcached

下载 wget http://www.memcached.org/files/memcached-1.6.6.tar.gz

解压缩包 tar zxf memcached-1.6.6.tar.gz

进入源码目录 cd memcached-1.6.6

编译安装 ./configure --prefix=/usr/local/memcached && make && make install

安装 libmemcached

下载 wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

解压缩包 tar zxf libmemcached-1.0.18.tar.gz

进入源码目录 cd libmemcached-1.0.18

编译安装 ./configure --prefix=/usr/local/libmemcached && make && make install

生成并安装扩展

下载 wget https://github.com/php-memcached-dev/php-memcached/archive/master.zip

解压缩包 unzip master.zip

进入源码目录 cd php-memcached-master

准备编译环境 /usr/local/php/bin/phpize

生成扩展 ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached && make && make install

安装扩展 vi /usr/local/php/lib/php.ini 添加 extension=memcached.so

使用Memcached加速WordPress

下载 https://github.com/tollmanz/wordpress-pecl-memcached-object-cache/archive/master.zip

解压后把 object-cache.php 放到 wp-content 目录内即可。

查看Memcached的使用情况

下载 http://pecl.php.net/get/memcache-3.0.8.tgz 编辑里面的 memcache.php 根据提示设置好用户名和密码,以及Memcached的相关信息,上传到服务器访问,即可查看。

安装过程中可能出现的报错以及解决办法

configure: error: libevent is required.  You can get it from https://www.monkey.org/~provos/libevent/
If it's already installed, specify its path using --with-libevent=/dir/

解决办法 yum install libevent-devel

./libtool: line 1125: g++: command not found
make[1]: *** [Makefile:5858: libhashkit/libhashkit_libhashkit_la-aes.lo] Error 1
make[1]: Leaving directory '/root/memcached-1.6.6/libmemcached-1.0.18'
make: *** [Makefile:3700: all] Error 2

解决办法 yum install gcc-c++

clients/memflush.cc:42:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   if (opt_servers == false)
                      ^~~~~
clients/memflush.cc:51:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if (opt_servers == false)
                        ^~~~~
make[1]: *** [Makefile:5832: clients/memflush.o] Error 1
make[1]: Leaving directory '/root/memcached-1.6.6/libmemcached-1.0.18'
make: *** [Makefile:3700: all] Error 2

解决办法 vi clients/memflush.cc 把第42行和第51行的 if (opt_servers == false) 更改为 if (!opt_servers)

configure: error: no, libmemcached built with sasl disabled. Run configure with --disable-memcached-sasl or update libmemcached with sasl support

解决办法 yum install cyrus-sasl-devel

CentOS编译安装PHP的Memcached扩展》有1个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注