Switch to PHP 7 after that,Site speed boost,But usually just one of extension may not yet support PHP7.
Memcached
For example, I now use the latest Ubuntu 16.04,Although it built in PHP 7 source,But it has not memcached,Fortunately, however,,It has supported PHP 7 ,Not just the source of it,We compile it manually。
To install memcached,You need to install the dependent libraries libmemcached
FromHereFind the latest source package libmemcached,Then download。
1 2 3 4 5 6 |
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar -zxf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.18/ ./configure make make install |
After installing dependent libraries,We install memcached :
From github clone memcached,You need to switch manually to the branch php7,Or you will be prompted fatal error: ext/standard/php_smart_str.h: No such file or directory error。
1 2 3 4 5 6 7 |
git clone https://github.com/php-memcached-dev/php-memcached.git cd php-memcached/ git checkout php7 phpize ./configure --disable-memcached-sasl make make install |
Redis
Same,Redis actually have PHP 7 version,We get cloned from github project,Then you can manually switch to php7 branch:
1 2 3 4 5 6 7 |
git clone https://github.com/phpredis/phpredis.git cd phpredis/ git checkout php7 phpize ./configure make make install |
Start Expansion
Installation of light is not enough,We also need to edit the configuration file to enable PHP extensions to be loaded for the job, we /etc/php/7.0/fpm/php.this ,Add the following statement in the configuration file:
1 2 |
extension=memcached.so extension=redis.so |
Finally, use the command to restart the service PHP: service php7.0-fpm restart
WordPress
For WordPress is,Here we need to download a separate plug-in:https://github.com/tollmanz/wordpress-pecl-memcached-object-cache
Since the official plugin wp caching plugin library only supports memcache,We can only own download object-cache.php Files to your blog wp-content The directory。
If one day you no longer want to use memcached,Put the file deletion。
Other,If you ran more than a WordPress vps ,So, if you want to give them all caching enabled,You have to edit wp-config.php file,turn up define('WP_DEBUG', false); This line,In its lower starting a new line and enter the following:
1 2 |
define('WP_CACHE_KEY_SALT', md5(DB_NAME . logcg)); //其中 logcg 改为你博客的名字,没有特定要求但必须唯一不能重复。 |
Such,Every WordPress program can access it alone memcached Caching。
Other,If you are using WP Super Cache Caching plugin,At this time you should be able to go to its advanced settings to find the support options for memcached:)
Original article written by LogStudio:R0uter's Blog » Ubuntu 16.04 Adding memcached and redis extended PHP7
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1747.html