您好,登录后才能下订单哦!
这篇文章主要为大家展示了“如何手动为LiteSpeed安装eAccelerator和XCache”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何手动为LiteSpeed安装eAccelerator和XCache”这篇文章吧。
其实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安装eAccelerator和XCache”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。