wordpress使用memcached+batcache内存缓存加速

博客地址:http://zyjblogs.cn/

如果要安装最新的memcached等,需要安装Remi的软件源,官网地址:http://rpms.famillecollet.com/

yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

第一步:安装libevent

yum install –enablerepo=remi -y libevent libevent-devel

第二步:安装memcached

yum install –enablerepo=remi -y memcached

启动memcached服务

 service memcached start

#开机memcached自启动

chkconfig memcached on

查看memcached进程

ps -ef | grep memcached

第三步:安装php的memcached扩展模块

需要先安装依赖库 libmemcached

yum install –enablerepo=remi -y libmemcached libmemcached-devel
yum install –enablerepo=remi -y zlib zlib-devel
yum -y install gcc#编译用到如果用,一般来说都centos自带gcc

安装好依赖库之后,我们来安装 memcached 的php拓展(适用php7x,php5x)

git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
phpize
./configure --disable-memcached-sasl --with-libmemcached-die=/usr/local/libmemcached
make && make install

查找memcached.so

[root@nextcloud ~]# find / -name memcached.so
/usr/lib64/php/modules/memcached.so
/usr/local/src/php-memcached/.libs/memcached.so
/usr/local/src/php-memcached/modules/memcached.so

#编辑php.ini 添加 extension=/usr/lib64/php/modules/memcached.so
[root@nextcloud ~]# vim /etc/php.ini
……
extension=/usr/lib64/php/modules/memcached.so
……

重启服务

systemctl restart httpd

第四部:wordpress添加插件batcache

可以直接去后台插件搜索安装
当然也可以直接下载插件安装:https://wordpress.org/plugins/batcache/

下载插件然后解压得到advanced-cache.php上传到/wp-content/目录中。

memcached插件有两个地方可以下载,我们可以访问github项目页面下载插件包:

https://github.com/tollmanz/wordpress-pecl-memcached-object-cache

下载并解压得到的memcached-class-object-cache.php重命名为 object-cache.php,上传到 wp-content 目录

#然后编辑wp-config.php
vim wp-config.php

添加下面两条

define('WP_CACHE', true);
define('ENABLE_CACHE', true);

#放在如下位置

解析:define('ENABLE_CACHE', true);这段是激活Memcached; define('WP_CACHE', true);是激活Batcache;

猜你喜欢

转载自blog.csdn.net/qq_26018075/article/details/106034261