關于xcache的介紹可以看這里https://xcache.lighttpd.net
以WordPress為例:
首先是安裝xcache 具體可參照lnmp.org說明,然后去這里下載一個插件,不能在后臺安裝,而且也不是安裝在pluging目錄下的,https://wordpress.org/extend/plugins/xcache/
解壓后將object-cache.php文件上傳到你的博客路徑/wp-content/下面,然后就沒有然后了,如果內存夠大可以去php.ini里把xcache.size的值調大一點.
軍哥lnmp1.2一鍵安裝包
配置Xcache
修改php配置文件php.ini
配置時我們可以參考xcache的配置模板xcache.ini,此文件位于Xcache安裝程序中
- /usr/local/php/etc/php.ini
- [xcache-common]
- extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so"
- ;非windows 例子, xcache.so路徑
- [xcache.admin]
- xcache.admin.enable_auth = On
- ;開啟驗證
- xcache.admin.user = "xcache"
- ;驗證名
- xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"
- ;md5后的驗證密碼, 亦即echo -n "123456" | md5sum,留空則禁用管理頁面.
- [xcache]
- xcache.shm_scheme ="mmap"
- ; 決定 XCache 如何從系統分配共享內存
- xcache.size=60M
- ; 0 禁止, 非 0 則啟用緩存器. 請注意您系統所允許的 mmap 最大值.
- xcache.count =1
- ; 指定將 cache 切分成多少塊.(cat/proc/cpuinfo |grep -c processor)
- xcache.slots =8K
- ; 只是作為 hash 槽個數的參考值, 您可以放心地緩沖超過這個個數的項目.
- xcache.ttl=0
- ; 設置緩沖項目的 Ttl (Time To Live) 值, 0=永不過期.
- xcache.gc_interval =0
- ; 檢查過期項目, 回收內存空間的間隔.
- xcache.var_size=4M
- xcache.var_count =1
- xcache.var_slots =8K
- ; 同上, 不過用于數據緩沖而不是 opcode 緩沖.
- xcache.var_ttl=0
- ; xcache_(get|set|inc|dec) 等的默認 ttl 值.
- xcache.var_maxttl=0
- ; 最大 ttl 值, 程序無法指定超過這個最大值的 ttl.
- xcache.var_gc_interval =300
- xcache.test =Off
- xcache.readonly_protection = On
- ;如果啟用了 ReadonlyProtection, 將會略微降低性能, 但是會提高一定的安全系數. 這個選項對于xcache.mmap_path = /dev/zero 無效.
- xcache.mmap_path ="/tmp/xcache"
- ;緩存文件,不是目錄,需要手動創建
- xcache.coredump_directory =""
- xcache.cacher =On
- ;使用/不使用 opcode 緩存器. xcache.size = 0 時無效.
- xcache.stat=On
- ;使用 stat() 發現檢查腳本更新.
- xcache.optimizer =Off
- [xcache.coverager]
- xcache.coverager =On
- ;啟用代碼覆蓋信息采集到. 啟用后xcache.coveragedump_directory 設置以及xcache_coverager_start/stop/get/clean() 才可以使用. (啟用后會對降低影響)
- xcache.coverager_autostart = On
- //Vevb.com
- ;每個頁面請求自動調用 xcache_coverager_start
- xcache.coveragedump_directory =""
生成Xcache緩存文件
touch /tmp/xcache
chmod 777 /tmp/xcache
拷貝Xcache管理程序到網站根目錄下
cp -a /tmp/xcache-1.3.3/ htdocs/ 網站根目錄/xadmin
然后重新啟動php和web服務器
然后訪問http://localhost/xadmin,用戶名為xcache 密碼為123456;另外,還可以通過phpinfo來驗證PHP是否支持Xcache
點擊右上角的“診斷”,可以看到你目前的 Xcache 設置是否存在什么問題,而且給出了解釋和建議,非常人性化.
我的設置,替換后執行 reboot
- [xcache]
- xcache.shm_scheme = "mmap"
- xcache.size = 80M
- ; set to cpu count (cat /proc/cpuinfo |grep -c processor)
- xcache.count = 1
- xcache.slots = 16K
- xcache.ttl = 0
- xcache.gc_interval = 0
- xcache.var_size = 200M
- xcache.var_count = 1
- xcache.var_slots = 16K
- 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 = "/tmp/xcache"
- xcache.coredump_directory = ""
- xcache.experimental = Off
- xcache.cacher = On
- xcache.stat = On
- xcache.optimizer = On
- [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 = On
- xcache.coveragedump_directory = ""
- ;xcache end
新聞熱點
疑難解答
圖片精選