Install PHP's memcache extension

Summary: The website has an error Fatal error: Class 'Memcache' not found. The reason for the error is because of a problem with the memcache module. You need to install memcache and specify the memcache module in php.ini.

The website has an error Fatal error: Class 'Memcache' not found
. The reason for the error is because of a problem with the memcache module. You need to install memcache and specify the memcache module in php.ini.

The memcache extension method for installing PHP is as follows (only a module is installed here)

Download and compile and install the
memcache download address http://pecl.php.net/package/memcache

mem1

Here beta means the test version, stable is the stable version, according to Individuals need to choose, click the .tgz package under Downloads to download directly.

You can download the package and transfer it to the server, or you can use the wget command directly. The wget method I use here:

wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar xzfv memcache-2.2 .5.tgz
cd memcache-2.2.5
/usr/local/php/bin/phpize
You can run it according to the location of your own phpize (if you don't know where phpize is, directly find / -name phpize to find it), after running, the following information will be prompted, and then you can compile it Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519 Compile: ./configure
--enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
make
make install
Here's a hint:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

ll /usr/local/php/lib/php/extensions/no-debug-non -zts-20060613/
-rwxr-xr-x 1 root root 237136 Nov 26 16:51 memcache.so
modify the php.ini file
vim /usr/local/php/etc/php.ini (this is my path) find the extension Change to the following
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension=memcache.so Add this line by yourself, save and exit after

changing it.

Restart the php service
. #/etc/init.d/php-fpm restart
Check through phpinfo that the memcache module has been installed
mem2

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326177458&siteId=291194637