LNMP中安裝 Xcache 緩衝擴充,降低伺服器負載配置

來源:互聯網
上載者:User

倡萌一直都是用軍哥的 lnmp 一鍵安裝包來設定管理員環境,最近一個月來,網站流量上來了些,可能還有其他原因,導致伺服器負載不太穩定,負載時不時會飆升好幾倍甚至十幾倍,訪問就非常慢啦。昨天下午直接導致伺服器 nginx 進程死掉了,想來想去,最後還是決定配置 lnmp 1.1 ,順便安裝 Xcache 對象緩衝擴充,配合之前的 Memcached 記憶體緩衝一起,負載很明顯就下來了,記憶體佔用也小多了。

XCache 是一個國人開發的又快又穩定的 PHP opcode 緩衝器. 經過良好的測試並在大流量/高負載的生產機器上穩定運行。經過(在 linux 上)測試並支援所有現行 PHP 分支的最新發行版本。要瞭解更多資訊,請訪問官方文檔:http://xcache.lighttpd.net/

lnmp 安裝包已經整合了安裝指令碼,進入lnmp解壓後的目錄,執行:./xcache.sh 運行後有如下提示(1.1版本):

一個有兩個版本可以選擇,分別是XCache 2.0.1 和XCache 3.1.0 ,建議安裝 XCache 3.1.0 輸入new 斷行符號,出現“Press any key to start...or Press Ctrl+c to cancel“,再次斷行符號確認即可開始安裝。安裝過程會讓你輸入 Xcache 管理員密碼,輸入即可。預設管理使用者名是 admin。

安裝好以後,訪問 http://你的伺服器IP/xcache/    輸入admin使用者名稱和密碼就可以登入管理介面:

點擊右上方的“診斷”,可以看到你目前的 Xcache 設定是否存在什麼問題,而且給出瞭解釋和建議,非常人性化。

Xcache 的設定選項在 php.ini 裡,lnmp 1.1 自動添加的如下:
 代碼如下 複製代碼
;xcache
[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.enable_auth = On
;預設的管理使用者名,你可以修改 admin 為其他使用者名稱
xcache.admin.user = "admin" 
;run: echo -n "yourpassword" |md5sum |awk '{print }' to get md5 password 以下是密碼,就是安裝時設定的(MD5加密)
xcache.admin.pass = "5ed1b644b258a5cc83"
[xcache]
xcache.shm_scheme =        "mmap"
;對象緩衝的大小,預設好像是20M,可能不夠用,自己修改大些
xcache.size  =               20M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
xcache.slots =                8K
xcache.ttl   =                 0
xcache.gc_interval =           0
;變數緩衝大小,預設是 4M,一般的程式是沒有用到這個緩衝的,可以不理會
xcache.var_size  =            4M
xcache.var_count =             1
xcache.var_slots =            8K
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory. (auto create/overwrite)
; Use something like "/tmp/xcache" instead of "/dev/*" if you want to turn on ReadonlyProtection
; different process group of php won't share the same /tmp/xcache
xcache.mmap_path =    "/dev/zero"
xcache.coredump_directory =   ""
xcache.experimental =        Off
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =           Off
[xcache.coverager]
; enabling this feature will impact performance
; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value"
; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions
xcache.coverager =          Off
xcache.coveragedump_directory = ""
;xcache end
我們一般就修改一下管理使用者名 xcache.admin.user  和  對象緩衝大小 xcache.size  即可

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.