apc,xcache,eaccelerator都能够缓存opcode的PHP中间码,从而起到对PHP加速的作用,以前写过一篇关于eaccelerator的文章,请参考http://blog.51yip.com/php/172.html apc,eaccelerator安装方法都一样,不同的是参数设置不一样而已
一,apc安装配置
wget http://pecl.php.net/get/APC-3.1.2.tgz
tar zxvf APC-3.1.2.tgz
cd APC-3.1.2/
/usr/local/PHP/bin/PHPize
./configure --enable-apc --enable-apc-mmap --with-PHP-config=/usr/local/PHP/bin/PHP-config
make
make install
修改PHP.ini
查找extension_dir = "/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/"
下面添加 extension = "apc.so" 配置PHP.ini 末尾加入
apc.enabled = 1
apc.cache_by_default = on
apc.shm_segments = 1
apc.shm_size = 32
apc.ttl = 600
apc.user_ttl = 600
apc.num_files_hint = 0
apc.write_lock = On
二,xcache安装配置
wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
tar zxvf xcache-1.2.2.tar.gz
cd xcache
/usr/local/PHP/bin/PHPize
./configure --enable-xcache --enable-xcache-mmap --with-PHP-config=/usr/local/PHP/bin/PHP-config
make
make install
修改PHP.ini
查找extension_dir = "/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/"
下面添加 extension = "xcache.so" 配置PHP.ini 末尾加入
[xcache-common]
;; install as zend extension (recommended),normally "$extension_dir/xcache.so"
;; or install as extension,make sure your extension_dir setting is correct
; extension = xcache.so
[xcache.admin]
xcache.admin.auth = On
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""
[xcache]
xcache.shm_scheme = "mmap"
xcache.size = 32M
xcache.count = 1
xcache.slots = 8K
xcache.ttl = 3600
xcache.gc_interval = 300
; Same as aboves but for variable cache
; If you don't know for sure that you need this,you probably don't
xcache.var_size = 0M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
; N/A for /dev/zero
xcache.readonly_protection = Off
xcache.mmap_path = "/dev/zero"
xcache.cacher = On
xcache.stat = On
这三个加速都对opcode的PHP中间码对行缓存的,能不能同时使用,没有尝试过,不过eacc和apc,我同时使用过,不过有问题。网上有关于这三者加速的比较,查一下好多,有了就省得我来比较了。写的挺不错的。自己搜一下吧。
原文链接:https://www.f2er.com/redis/447330.html