1.memcache服务器的安装
1.分别把memcached和libevent下载回来,放到 /tmp 目录下: # cd /tmp # wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz # wget http://www.monkey.org/~provos/libevent-1.2.tar.gz 2.先安装libevent: # tar zxvf libevent-1.2.tar.gz # cd libevent-1.2 # ./configure --prefix=/usr # make # make install 3.测试libevent是否安装成功: # ls -al /usr/lib | grep libevent lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3 -rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3 -rw-r--r-- 1 root root 454156 11?? 12 17:38 libevent.a -rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3 还不错,都安装上了。 4.安装memcached,同时需要安装中指定libevent的安装位置: # cd /tmp # tar zxvf memcached-1.2.0.tar.gz # cd memcached-1.2.0 # ./configure --with-libevent=/usr # make # make install 如果中间出现报错,请仔细检查错误信息,按照错误信息来配置或者增加相应的库或者路径。 安装完成后会把memcached放到 /usr/local/bin/memcached , 5.测试是否成功安装memcached: # ls -al /usr/local/bin/mem* -rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached -rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug
2.扩展的安装
下载地址:https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
安装:
tar vxzf memcache-2.2.1.tgz cd memcache-2.2.1 /usr/local/php/bin/phpize ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir make make install
安装成功,会有如下提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
3.修改php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/" extension=memcache.so