手動為LiteSpeed安裝eAccelerator和XCache的方法

火幣

最近又開始玩起了LiteSpeed,就把安裝eacceleratorXCache的方法跟大家簡單分享一下吧。

其實這句話用「和」字不好,因為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 m4

2.安裝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 1

3.配置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重啟生效~

文章轉載自微魔部落

贊(9) 打賞
需要國外VPS建站朋友,請聯繫站長! 轉載請註明文章來源:VPSMVP部落 - 便宜VPS|VPS優惠|VPS測評|美國VPS|VPS教程 » 手動為LiteSpeed安裝eAccelerator和XCache的方法
分享到: 更多 (0)
VULTR

評論 搶沙發

  • 昵稱 (必填)
  • 郵箱 (必填)
  • 網址

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

微信掃一掃打賞




友情鏈接:
 |  趙容部落  |  老左筆記  |  微魔部落  |  便宜VPS  |  vps小學生  |  主機百科  |  老蔣部落  |  老劉博客  |  全球主機  |  全球主機交流  |  數字居民  |  LET論壇  |  veidc測評  |  挖站否  |  VPS收割者  |  主機貼士  |  惠主機  |  荒島  |  VPS GO  |  國外VPS  |  主機之家測評

友情鏈接申請