After Ubuntu16.04 adds memcached for PHP7 and redis extension switches to PHP 7, the website speed is greatly improved. However, a common extension may not support PHP7.
Memcached
For example, I have used the latest Ubuntu 16.04. Although PHP 7 is built in, memcached is not available yet. Fortunately, it supports PHP 7, but it only has no source, we compile it manually.
To install memcached, you must first install the dependency LibraryLibmemcached
Find the latest libmemcached source code package and download it.
wgethttps://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gztar -zxflibmemcached-1.0.18.tar.gzcdlibmemcached-1.0.18/./configuremakemakeinstall
After installing the dependency library, we will install memcached:
After cloning memcached from github, you need to manually switch to the php7 branch. Otherwise, the error "fatal error: ext/standard/php_smart_str. h: No such file or directory" is returned.
gitclone https://github.com/php-memcached-dev/php-memcached.gitcdphp-memcached/gitcheckoutphp7phpize./configure --disable-memcached-saslmakemakeinstall
Redis
Similarly, Redis already has PHP 7. we can get the project clone from github and manually switch to the PHP 7 branch:
gitclone https://github.com/phpredis/phpredis.gitcdphpredis/gitcheckoutphp7phpize./configuremakemakeinstall
Start extension
It is not enough to install the plug-in. we also need to edit the PHP configuration file to load the extension. vi/etc/php/7.0/fpm/php. ini, add the following statement to the configuration file:
extension=memcached.soextension=redis.so
Run the following command to restart the PHP service: service php7. 0-fpm restart.