libevent是为了取代事件循环发现在事件驱动的网络服务器。一个应用程序只需要调用event_dispatch(),然后添加或删除事件动态而无需更改事件循环。 libevent 与memcached 的关系? libevent 下载地址:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz tar zxvf libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-stable ./configure --prefix=/usr make&make install
输入以下命令,查看是否有目录列出(检查是否安装成功)
ls -al /usr/lib | grep libevent
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar zxvf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.18 ./configure --prefix=/usr/local/webserver/libmemcached --with-memcached make && make install
这里make需要g++支持,如果报错缺少g++请根据操作系统执行以下代码,并删除目录重新configure、make:
CentOS: sudo yum install g++ Ubuntu: sudo apt-get install g++
wget http://www.memcached.org/files/memcached-1.4.17.tar.gz tar xvf memcached-1.4.17.tar.gz cd memcached-1.4.17 ./configure --prefix=/usr/local/webserver/memcached --with-libevent=/usr make make install
/usr/local/webserver/memcached/bin/memcached -d -m 2048 -u root -p 12111 -c 1024 -P /tmp/memcached.pid
tar zxvf memcached-1.0.2.tar.gz cd memcached-1.0.2 #请根据实际情况自行运行phpize /usr/local/webserver/php/bin/phpize #请根据实际情况自行调整参数路径 ./configure --enable-memcached --with-php-config=/usr/local/webserver/php/bin/php-config --with-libmemcached-dir=/usr/local/webserver/libmemcached --prefix=/usr/local/webserver/memcached --with-memcached --disable-memcached-sasl make && make install
当出现如下内容时,代表安装成功
Installing shared extensions: /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
php.ini文件中加入如下内容:
extension=memcached.so
phpinfo()页面出现如下内容