安装完php的memcache扩展后,写了个测试的php脚本,但是通过浏览器访问时出错。
错误信息如下:
Fatal error: Class ‘Memcache’ not found in /usr/local/nginx/html/memcache-test.php on line 2
可能原因:
php的memcache扩展没有安装成功。
解决办法:
cd /root/soft/php-5.2.17
./configure –help|grep memcache ###没有返回,说明php不支持memcache
#重新生成configure文件。
cp /root/soft/memcache-2.0.4.tgz /root/soft/php-5.2.17/ext
cd /root/soft/php-5.2.17/ext
tar zxvf memcache-2.0.4.tgz
mv memcache-2.0.4 memcache
cd ..
mv configure configure.bak
./buildconf –force
#查看是否支持memcache
./configure –help|grep memcache
–enable-memcache Enable memcache support
–disable-memcache-session Disable memcache session handler support
–with-zlib-dir=DIR memcache: Set the path to ZLIB install prefix.
重新编译,添加–enable-memcache
./configure –prefix=/usr/local/php –enable-fastcgi –enable-fpm –enable-memcache
make&&make install
killall -HUP nginx
/usr/local/php/sbin/php-fpm restart
测试:
问题解决,访问正常。