亲宝软件园·资讯

展开

手动为LiteSpeed安装eAccelerator和XCache的方法分享

人气:0
其实这句话用“和”字不好,因为eAccelerator和XCache并不兼容,你只能忍痛割爱选择其一,但貌似eAccelerator对新版5.4的PHP支持不好,因此高版本的PHP,XCache算是更好的选择。至于两者的具体对比,不在本文的涉及之列,大家可以自行网络搜索~在阅读本文前,强烈阅读本站关于LiteSpeed的相关教程,比如LiteSpeed的安装方法面板的配置

其实LiteSpeed在编译PHP的时候有这两个组件可选,但为什么微魔要单独手动安装呢?原因是官方的这两个组件勾选后经常出现无法解析等问题,这一问题和具体你使用的VPS似乎无关,而和官网链接的时常抽风有关,因此,为了避免卡在Compile PHP的第一步,可以暂时取消这两个组件,像本文一样,手动安装~

无论安装哪一个,请先确保/usr/local/lsws/lsphp5/lib/php.ini是否存在,若不存在,执行如下命令

cp /usr/local/lsws/php/php.ini /usr/local/lsws/lsphp5/lib/

无论你选择安装哪一个,最后都请在LiteSpeed面板里Graceful Restart重启生效~
安装eAccelerator
1.安装必要的依赖文件(很多时候这一步其实是多此一举,但是为了避免出错,还是做吧~)

本文我以Debian为例,至于CentOS,可以讲文中apt-get换成yum,基本可以通用~

apt-get install autoconf automake libtool m42.安装eAccelerator

可自行到官网查询最新版的下载链接,替换下面的url(前往官网下载页


cd ~
wget https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
/usr/local/lsws/lsphp5/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/lsws/lsphp5/bin/php-config
make
make install


如果你默认在LiteSpeed里编译的是PHP 5.4,进行make的时候可能出现如下错误,原因可能是新版对5.4的不兼容造成的。要么改装XCache,要么就换PHP 5.3吧


/home/package/eaccelerator-0.9.6.1/eaccelerator.c: In function ‘eaccelerator_restore’:
/home/package/eaccelerator-0.9.6.1/eaccelerator.c:878: warning: assignment discards qualifiers from pointer target type
/home/package/eaccelerator-0.9.6.1/eaccelerator.c: In function ‘eaccelerator_compile_file’:
/home/package/eaccelerator-0.9.6.1/eaccelerator.c:1317: error: ‘zend_class_entry’ has no member named ‘line_start’
/home/package/eaccelerator-0.9.6.1/eaccelerator.c: At top level:
/home/package/eaccelerator-0.9.6.1/eaccelerator.c:1913: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘eaccelerator_functions’
/home/package/eaccelerator-0.9.6.1/eaccelerator.c:1938: error: ‘eaccelerator_functions’ undeclared here (not in a function)
make: *** [eaccelerator.lo] Error

13.配置eAccelerator生效(这一部分在前面的文章里讲过,这里不多说了~)


mkdir /usr/local/eaccelerator_cache
chmod -R 777 /usr/local/eaccelerator_cache
vi /usr/local/lsws/lsphp5/lib/php.ini

在php.ini文件末尾加入如下字段


[eaccelerator]
zend_extension="/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="1"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"

检测php.ini文件是否正常


/usr/local/lsws/lsphp5/bin/php -v

不出意外的话应该不会报错~

安装XCache
1.安装Xcache(查看官网最新版本


cd ~
wget http://xcache.lighttpd.net/pub/Releases/3.0.0/xcache-3.0.0.tar.gz
tar zxvf xcache-3.0.0.tar.gz
cd xcache-3.0.0
/usr/local/lsws/lsphp5/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/lsws/lsphp5/bin/php-config
make
make install

make install后会给出一个目录,记下来备用,根据litespeed的版本不同,似乎这个目录名也不同~我的是/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20100525/
2.修改php.ini文件


vi /usr/local/lsws/lsphp5/lib/php.ini

在末尾加入以下内容


extension_dir = "/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20100525/"
extension="xcache.so"
[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

其中,密码字段xcache.admin.pass可自定义,用md5加密你要的密码填入,比如

echo -n "vmvps" | md5sum

3.检验php.ini是否出错

/usr/local/lsws/lsphp5/bin/php -v

如果出现如下错误

PHP Fatal error: Directive 'allow_call_time_pass_reference' is no longer available in PHP in Unknown on line 0可以通过以下命令解决

perl -pi -e 's/^allow_call_time_pass_reference/;allow_call_time_pass_reference/' /usr/local/lsws/lsphp5/lib/php.ini

本文到此结束,还是那句话,无论你选择安装哪一个,最后都请在LiteSpeed面板里Graceful Restart重启生效~

加载全部内容

相关教程
猜你喜欢
用户评论