導讀:搭建網站搭建網站環境: 一個本地開發環境 一個部署在虛擬機中( 虛擬機安裝memcache緩存),然后用這個優化的版本跟本地開發環境對比. wordpress版本:4.9.5 網站搭建seo建站技術。

環境:
一個本地開發環境
一個部署在虛擬機中( 虛擬機安裝memcache緩存),然后用這個優化的版本跟本地開發環境對比.
wordpress版本:4.9.5
php:5.6版本
1,首先在主題的functions.php文件中,加入以下監控統計代碼
function?performance(?$visible?=?true?)?{
????$stat?=?sprintf(??'%d?queries?in?%.3f?seconds,?using?%.2fMB?memory',
????????get_num_queries(),
????????timer_stop(?0,?3?),
????????memory_get_peak_usage()?/?1024?/?1024
????);
????//?echo?$visible???$stat?:?"<!--?{$stat}?-->"?;
????echo?"<div?class='container_12'><p?class='grid_12?footer?clearfix'>$stat</p></div>";
}
add_action(?'wp_footer',?'performance',?20?);
樣式可以根據自己的主題定制,這段代碼可以統計出頁面有多少次數據庫查詢??偣不硕嗌倜?,耗費多少內存,類似如下的樣式:
16?queries?in?1.306?seconds,?using?12.98MB?memory
2,安裝memcached服務端
[root@bogon?wp-content]#?ps?-ef?|?grep?memcached
root??????5050??3466??0?14:44?pts/1????00:00:00?grep?memcached
root?????29269?????1??0?13:57??????????00:00:02?/usr/local/memcached/bin/memcached?-d?-l?127.0.0.1?-p?11211?-u?root?-m?64?-c?1024?-P?/var/run/memcached.pid
3,安裝php memcache擴展
wget http://pecl.php.net/get/memcache-3.0.8.tgz,用phpize外掛方式安裝,安裝完成之后,在php.ini中啟用,再重啟php,確定memcache已經加載
memcache
memcache?support????enabled
Version????3.0.8
Revision????$Revision:?329835?$
Directive????Local?Value????Master?Value
memcache.allow_failover????1????1
memcache.chunk_size????32768????32768
memcache.compress_threshold????20000????20000
memcache.default_port????11211????11211
memcache.hash_function????crc32????crc32
memcache.hash_strategy????consistent????consistent
memcache.lock_ti織夢模板下載meout????15????15
memcache.max_failover_attempts????20????20
關鍵詞標簽: WordPress div memcache
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-23 ,文章使用memcache對wordpress優化,提速,搭建網站主要講述div,memcache,wordpress網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_35443.html