首页课件丨教程安装教程为WordPress安装Memcached对象缓存

为WordPress安装Memcached对象缓存

WordPress的对象缓存是一种缓存由插件和主题设置的瞬态的方法。默认的WordPress对象缓存使用了MySQL数据库,开发人员一直寻找替代方法来将这些瞬变存储在其他位置,以加快WordPress性能。RedisMemcached都是用于将瞬态存储在RAM中的对象缓存守护程序。

本教程将展示如何安装Memcached服务器和PHP 7扩展,以便WordPress可以与Memcached服务器交互。

安装Memcached服务器

从存储库安装最新的Memcached守护程序和依赖项。

Ubuntu:

sudo apt install libmemcached* memcached libanyevent-perl libyaml-perl libterm-readkey-perl libevent-dev libsasl2-2 sasl2-bin libsasl2-dev php7.0-dev php7.0-json php-igbinary php-msgpack pkg-config libtool-bin build-essential git -y

Centos:

yum install memcached yum install php-memcached

为WordPress配置Memcached

备份原始的Memcached配置文件:

sudo mv /etc/memcached.conf /etc/memcached.conf.bak 

创建一个新的Memcached配置文件:

sudo nano /etc/memcached.conf

粘贴此memcached配置:

# Run memcached as a daemon. This command is implied, and is not needed for the # daemon to run. See the README.Debian that comes with this package for more # information. -d # Log memcached's output to /var/log/memcached logfile /var/log/memcached.log # Be verbose # -v # Be even more verbose (print client commands as well) # -vv # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default # Note that the daemon will grow to this size, but does not start out holding this much # memory -m 50 # Default connection port is 11211 -p 11211 # Run the daemon as root. The start-memcached will default to running as root if no # -u command is present in this config file -u memcache # Specify which IP address to listen on. The default is to listen on all IP addresses # This parameter is one of the only security measures that memcached has, so make sure # it's listening on a firewalled interface. -l 127.0.0.1 # Set unix socket which we put in the folder /var/run/memcached and made memcache user the owner #-s /var/run/memcached/memcached.sock # set permissions for the memcached socket #-a 775 # Limit the number of simultaneous incoming connections. The daemon default is 1024 # -c 1024 # Lock down all paged memory. Consult with the README and homepage before you do this # -k # Activate optimal options -o modern

Ctrl + X,Y并按Enter保存并退出

打开Memcached init.d配置文件:

sudo nano /etc/default/memcached

确定有下面这一行,以便Memcached启动。

# Set this to no to disable memcached. ENABLE_MEMCACHED=yes

重新启动Memcached:

sudo service memcached restart

安装Memcached PHP 7 PECL扩展

编译Memcached PHP 7 PECL扩展:

sudo apt install php7.0-dev libtool pkg-config php-igbinary php-json php-msgpack -y cd /tmp git clone https://github.com/php-memcached-dev/php-memcached -b php7 cd php-memcached libtoolize phpize ./configure --prefix=/usr --enable-memcached-igbinary --enable-memcached-json --enable-memcached-msgpack sudo make sudo make install

为nginx或Apache启用PHP 7扩展

添加memcached扩展:

echo "extension = memcached.so" | sudo tee -a /etc/php/7.0/mods-available/memcached.ini

重新启动php7.0-fpm

sudo service php7.0-fpm restart

重新启动Apache2或nginx

sudo service apache2 restart

安装Memcached WordPress插件(兼容PHP 7.x)

安装并启用插件后,在WordPress后台 “工具 > Memcached”中可以看到以下信息:

声明: 1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:ceo@zunw.cn,我们将第一时间处理! 2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持 3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明。

给TA赏金
共{{data.count}}人
人已赏金
安装教程

GeneratePress主题搭配GenerateBlocks建站的优势

2022-11-9 23:00:19

安装教程

站长帮网站SEO优化成果分享,感谢大家支持!

2022-11-9 23:00:21

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索
MySSL 安全签章