VPSMVP部落 - 便宜VPS|VPS优惠|VPS测评|美国VPS|外贸VPS|VPS教程|域名优惠|主机优惠

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

感觉很久没发vps教程类的文章了,正好最近又开始玩起了LiteSpeed,就把安装eacceleratorXCache的方法跟大家简单分 享一下吧。其实这句话用“和”字不好,因为eAccelerator和XCache并不兼容,你只能忍痛割爱选择其一,但貌似eAccelerator对 新版5.4的PHP支持不好,因此高版本的PHP,XCache算是更好的选择。

至于两者的具体对比,不在本文的涉及之列,大家可以自行网络搜索~

在阅读 本文前,强烈阅读本站关于LiteSpeed的相关教程,比如LiteSpeed的安装方法和面板的配置。

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

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

[notification type="info"] cp /usr/local/lsws/php/php.ini
/usr/local/lsws/lsphp5/lib/[/notification]

无论你选择安装哪一个,最后都请在LiteSpeed面板里Graceful Restart重启生效~

安装eAccelerator

1.安装必要的依赖文件(很多时候这一步其实是多此一举,但是为了避免出错,还是做吧~)

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

[notification type="info"] apt-get install autoconf automake libtool m4[/notification]

2.安装eAccelerator

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

[notification type="info"] 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[/notification]

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

[notification type="info"] /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 1[/notification]

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

[notification type="info"] mkdir /usr/local/eaccelerator_cache
chmod -R 777 /usr/local/eaccelerator_cache
vi /usr/local/lsws/lsphp5/lib/php.ini[/notification]

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

[notification type="info"] [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"[/notification]

检测php.ini文件是否正常

[notification type="info"] /usr/local/lsws/lsphp5/bin/php -v[/notification]

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


安装XCache

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

[notification type="info"] 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[/notification]

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

2.修改php.ini文件

[notification type="info"] vi /usr/local/lsws/lsphp5/lib/php.ini[/notification]

在末尾加入以下内容

[notification type="info"] 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[/notification]

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

[notification type="info"] echo -n "vmvps" | md5sum[/notification]

3.检验php.ini是否出错

[notification type="info"] /usr/local/lsws/lsphp5/bin/php -v[/notification]

如果出现如下错误

PHP Fatal error:  Directive 'allow_call_time_pass_reference' is no longer available in PHP in Unknown on line 0

可以通过以下命令解决

[notification type="info"] perl -pi -e 's/^allow_call_time_pass_reference/;
allow_call_time_pass_reference/' /usr/local/lsws/lsphp5/lib/php.ini[/notification]

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

文章转载自微魔部落

转载请注明文章来源:VPSMVP部落 - 便宜VPS|VPS优惠|VPS测评|美国VPS|外贸VPS|VPS教程|域名优惠|主机优惠 » 手动为LiteSpeed安装eAccelerator和XCache的方法

分享到:

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址