FastCGI模式下安装Xcache

PHP执行的时候,会被编译成opcode,然后 zend引擎会执行opcode.也就是说,如果你两次执行同一个php程序,每次执行,他都要把php代码编译成opcode
xcache的意义在于,当你第一次执行php的,他编译opcode的时候,会把这个opcode缓存起来,当你第二次执行这个php程序的时候,他就直接使用缓存中的opcode,不需要从新编译一次.这样就提高了执行效率

CentOS7.2下安装php加速软件Xcache(在php主机上完成下面的操作)


说明:

php安装目录:/usr/local/php5.6

php.ini配置文件路径:/etc/php.ini

php网页根目录:/var/www/benet

1)安装xcache

wgethttp://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz #下载

[root@phpserver~]# tar zxf xcache-3.2.0.tar.gz #解压

[root@phpserver~]# cd xcache-3.2.0/ #进入安装目录

[root@phpserverxcache-3.2.0]# /usr/local/php5.6/bin/phpize #用phpize生成configure配置文件

[root@phpserverxcache-3.2.0]# ./configure --enable-xcache --enable-xcache-coverager--enable-xcache-optimizer --with-php-config=/usr/local/php5.6/bin/php-config &&make&& make install



Installing shared extensions:

/usr/local/php5.6/lib/php/extensions/no-debug-zts-20131226/

安装完成之后,出现下面的界面,记住以下路径,后面会用到

/usr/local/php5.6/lib/php/extensions/no-debug-zts-20131226/

2)创建xcache缓存文件

# touch/tmp/xcache

# chmod 777/tmp/xcache

3)拷贝xcache后台管理程序到网站根目录

[root@phpserverxcache-3.2.0]# cp -r htdocs/ /var/www/benet/xcache

4)配置php支持xcache

vi /etc/php.ini #编辑配置文件,在最后一行添加以下内容

[xcache-common]

extension =/usr/local/php5.6/lib/php/extensions/no-debug-zts-20131226/xcache.so

[xcache.admin]

xcache.admin.enable_auth= Off

[xcache]

xcache.shm_scheme="mmap"

xcache.size=60M

xcache.count=1

xcache.slots=8K

xcache.ttl=0

xcache.gc_interval=0

xcache.var_size=64M

xcache.var_count=1

xcache.var_slots=8K

xcache.var_ttl=0

xcache.var_maxttl=0

xcache.var_gc_interval=300

xcache.test=Off

xcache.readonly_protection= Off

xcache.mmap_path="/tmp/xcache"

xcache.coredump_directory=""

xcache.cacher=On

xcache.stat=On

xcache.optimizer=Off

[xcache.coverager]

xcache.coverager=On

xcache.coveragedump_directory=""

将xcache目录拷贝到apache主机的网页文档目录下

[root@phpserver~]# scp -r /var/www/benet/xcache/ root@192.168.31.83:/var/www/benet/

5)测试

servicephp-fpm restart #重启php-fpm

浏览器打开网站根目录下面的xcache

http://http://192.168.31.83/xcache可以看到如下页面
原文地址:https://www.cnblogs.com/peteremperor/p/10944337.html