First, download and install XCache
# wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz// 下载# tar -zxvf xcache-3.2.0.tar.gz // 解压# cd xcache-3.2.0// 进入# /opt/lampp/bin/phpize// 扩展xcache模块# ./configure --enable-xcache --with-php-config=/opt/lampp/bin/php-config// 生成makefile# make; make install
You will eventually see the following:
Second, configuration php.ini file
[xcache-common]extension = Xcache. so #载入扩展模块[Xcache. Admin]xcache. Admin. Enable_auth = On#启用或禁用管理账单身份验证XCache. Admin. User="XCache" #管理认证用户名XCache. Admin. Pass="" #管理认证密码, MD5 encryption, default is empty[Xcache]xcache. Size= -M#所用共享缓存大小, 0 o'clock, cannot use cacheXCache. Count=1 #缓存被分割的 number of blocks, set to 1 by defaultXCache. Slots=8K#哈希表提示. The higher the speed, the higher the memory occupancy rateXCache. TTL=0 #Opcode文件的生存时间. 0 means indefiniteXCache. GC_interval =0 #触发垃圾回收的时间间隔, the default setting is 0XCache. var_size=4M#变量大小XCache. var_count =1 #变量个数XCache. var_slots =8K#可变数据槽设置XCache. var_ttl=0 #可变数据的生存时间XCache. var_maxttl=0 #处理变量时最大的生存时间XCache. var_gc_interval = - #垃圾回收的生存时间XCache. Test=off#启用或禁用测试功能XCache. ReadOnly_protection = On#启用readonlyProtection时可用 slows down the tool, but is more secureXCache. Mmap_path ="/opt/lampp/temp/xcache" #用于制度保护的文件路径,XCache. Coredump_dir ="" #在遇到故障时, the directory where the core dumps are placedXCache. Cacher=on#启用或禁用OpcodeXCache. Optimizer=off#启用或禁用优化, the default is disable[XCache. Coverager]xcache. Coverager=on#启用覆盖范围数据集合, when enabled slows down the running processXCache. Coveragedump_directory ="" #放置数据集合信息的目录位置.
Iii. opcode Cache selection 3.1 php life cycle
PHP script Generation opcode process
Every time a request is made to a script, he must perform all of the following steps. Through observation. The process of generating opcode is necessary at the time of first execution. However, in subsequent requests, this is not necessary. You can reduce the following three steps by first generating opcode, then caching, and then executing. thereby improving program performance.
3.2 Why use XCache
Choose XCache to do the opcode cache. Is the stability of its community, constantly updated. To use APC, we found that 5.6 of PHP does not seem to support an APC extension. And APC has not planned to upgrade for several years now.
Of course, there is another choice of EA, more powerful features. However, after my comprehensive comparison, XCache update very fast, and he was written by the Chinese, support a bar. But the EA is actually better than xcache in performance.
CentOS install XCache to cache opcode