首页 > 代码库 > 安装 XCache

安装 XCache

一、安装前提

(1) 安装好 LNMP 完整环境
(2) Nginx 能够解析 PHP
(3) 配置环境变量:echo ‘export LC_ALL=C‘ >> /etc/profile && source /etc/profile 2> /dev/null
(4) 安装 Perl 相关依赖:yum install -y perl-devel
(5) 注意:eAccelerator 、XCache 、ZendOpcache 都是缓存加速器,安装时只安装其中一个,首选 XCache

二、安装 XCache

cd /usr/local/src/wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.bz2yum install -y bzip2tar xf xcache-3.2.0.tar.bz2cd xcache-3.2.0/usr/local/php/bin/phpize./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-configmake && make installcd ..

 

三、配置 XCache

[root@localhost ~]# vim /usr/local/src/xcache-3.2.0/xcache.inixcache.size = 256M           # 缓存大小xcache.count = 2             # 指定将缓存对象切分成多少块,根据CPU数量来修改xcache.ttl = 86400           # 设置缓存对象的生存期xcache.gc_interval = 3600    # 回收器扫描过期的对象回收内存空间的间隔,单位为秒xcache.var_size = 64M        # 用于变量缓存
[root@localhost ~]# vim /etc/sysctl.confkernel.msgmnb = 65535kernel.msgmax = 65535kernel.shmmax = 68719476736kernel.shmall = 4294967196
cat /usr/local/src/xcache-3.2.0/xcache.ini >> /usr/local/php/lib/php.inipkill php-fpm/usr/local/php/sbin/php-fpm
[root@localhost ~]# /usr/local/php/bin/php -v     # 检查加速情况PHP 5.3.27 (cli) (built: May  5 2017 07:35:34)Copyright (c) 1997-2013 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies    with XCache v3.2.0, Copyright (c) 2005-2014, by mOo    with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo

 

四、配置图形界面查看 XCache 缓存加速信息

[root@localhost ~]# echo -n "123456" | md5sum     e10adc3949ba59abbe56e057f20f883e  -
[root@localhost ~]# vim /usr/local/php/lib/php.ini[xcache.admin]xcache.admin.enable_auth = Onxcache.admin.user = "pzk"xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"        # 账号为 pzk,密码为上面生成的 123456
cd /usr/local/src/xcache-3.2.0cp -a htdocs/ /usr/local/nginx/html/wordpress/xadmin          # 红色部分修改为对应的网站目录chown -R nginx.nginx /usr/local/nginx/html/wordpress/xadminpkill php-fpm/usr/local/php/sbin/php-fpm

访问:www.wordpress.com/xadmin/index.php

技术分享

 

 

 

    

安装 XCache