一直用wordpress做博客,而且不喜歡備案,所以只能放在海外,但是海外的主機訪問速度不給力,使用了xcache和eAccelerator效果不佳,后來使用了redis這個kv緩存服務后,速度明顯的提高5-6倍.
1.在vps主機上安裝redis
①我用的LNMP包,里面自帶了redis,執行 ./redis.sh 就可以自動安裝并加入自啟動
②單獨安裝redis-server
# apt-get install redis-server
啟動redis-server,并加入自啟動項目(具體方法請自行查閱,因為部分linux上的方法是不同的).
2.在wordpress中增加redis-Server的PHP客戶端
大家都推薦使用predis.php(下載地址),將predis.php上傳到wp的根目錄
3.下載wp使用redis的新首頁
index-with-redis.php(下載地址),將原來wp中的index.php備份,修改index-with-redis.php為index.php
4.根據個人需求修改index-with-redis.php中的參數
- // change vars here
- $cf = 1; // set to 1 if you are using cloudflare
- $debug = 0; // set to 1 if you wish to see execution time and cache actions //開源軟件:Vevb.com
- $display_powered_by_redis = 1; // set to 1 if you want to display a powered by redis message with execution time, see below
5.上傳到wp根目錄,刷新網頁即可
注意:如果wp升級了,那上述步驟中的兩個文件需要重新設置一下,接下來快去升級和加速你的wordpress站點吧,別猶豫了.
新聞熱點
疑難解答
圖片精選