使用wordpress時(shí)間比較長的朋友很可能會(huì)遇到這樣的問題,某一天,你的主機(jī)空間商突然給你一封郵件,告訴你你的網(wǎng)站資源占用太高,所以你的空間被暫停了,請(qǐng)你處理之后再幫你開通。
這樣的問題對(duì)于像我們這樣對(duì)技術(shù)并不特別了解的人來說,會(huì)直接不知所措。所以,在這里,我把所有可能造成wordpress資源占用過高的因素進(jìn)行了總結(jié)。希望對(duì)你有所幫助。
1、wordpress插件的問題
wordpress的主程序是設(shè)計(jì)的非常強(qiáng)健的,一般來說,不會(huì)有什么問題,但插件就不一樣了。
由于wordpress是一個(gè)開源的程序系統(tǒng),所以誰都可以為它編寫插件,但各種各樣的插件,并不一定能保證程序的質(zhì)量,特別是有的插件很可能已經(jīng)很長時(shí)間沒有更新,導(dǎo)致跟最新的wordpress版本并不兼容,所以它們很有可能導(dǎo)致主機(jī)資源占用過高。
所以,如果你的主機(jī)資源占用過高,第一個(gè)要檢查的就是你使用了哪些插件,把沒用的和可能沒用的插件都刪除掉,再試試看。而且以后注意盡量少用插件,特別是來源不明的插件。
2、網(wǎng)站本身流量太大
wordpress本身是一個(gè)博客程序 ,但如果你把它當(dāng)做CMS系統(tǒng)來用的話,可能網(wǎng)站本身流量就非常巨大,這樣的情況下,也很可能會(huì)導(dǎo)致主機(jī)資源占用過高。這時(shí)候,你可以嘗試使用WP Super Cache插件,它會(huì)把所有的頁面進(jìn)行靜態(tài)化處理,對(duì)本身流量巨大的網(wǎng)站來說,會(huì)顯著降低主機(jī)資源占用。但請(qǐng)注意,對(duì)一般的小網(wǎng)站來說,請(qǐng)不要使用這一類的緩存插件,否則得不嘗失。
3、定時(shí)類插件
這一點(diǎn)可能很多人都沒注意過,wordpress有很多有名的插件都在使用定時(shí)類插件,比如WP-DB-Backup插件之類的備份插件,都有定時(shí)備份的功能。但我要說的是,盡量不要使用定時(shí)任務(wù)的功能,因?yàn)椴划?dāng)?shù)亩〞r(shí)任務(wù)可能會(huì)導(dǎo)致死鎖,從而導(dǎo)致主機(jī)資源占用過高。具體的技術(shù)細(xì)節(jié)我也沒有深究過,但wordpress教程網(wǎng)以前也經(jīng)歷過這樣的問題,下面是主機(jī)商發(fā)給我的信件,其中的wp-cron.php就是處理定時(shí)任務(wù)的。
This message is to advise you of a temporary block placed on your account. This account was found to be consuming an inordinate amount of processor time, to the point of degrading overall system performance. While we do limit each account to no more than 25% of a system's CPU in our terms of service, we do not actively disable accounts until they greatly exceed that number, which is what happened in this case.
Requests to this scripts under this account may become degraded by limiting the abilty for scripts to run for a limited amount of time, or if the issue persists, we may be forced to restrict how fast processes can be spawned until the issue has been resolved.
We recommend taking steps to reduce the overall CPU usage for the account, which may be as simple as generating a flat HTML page for popular content, or enabling caching that is available through many popular scripts, or disabling high CPU usage features such as searches or Ajax refreshes. Although we may not be able to help in all cases, we would be more than happy to assist if you are unable to determine any cause, or if you need help interpreting any of the information.
CPU seconds used in the past hour: 2784.30999999998, 78% CPU
Current Site Requests:
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343898872.41504096984863281250
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343938404.43561100959777832031
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343938408.42049503326416015625
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343938410.08629703521728515625
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343938411.93777894973754882812
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343940419.26733207702636718750
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343940421.87949395179748535156
174.120.152.98 wpcourse.com /wp-cron.php?doing_wp_cron=1343940427.10176396369934082031
4、wordpress版本的問題
最后要說的就是,盡量讓你的wordpress更新到最新版本,因?yàn)閣ordpress全球使用的人數(shù)實(shí)在是很多,所以同樣有很多黑客之類的人在想方設(shè)法的找wordpress的漏洞,每次wordpress更新都會(huì)修復(fù)一些可能的漏洞,所以,更新到最新版本才能避免潛在的漏洞暴露在別有用心的人面前。
今天先說到這里,如果有漏掉的歡迎補(bǔ)充。來源:WordPress教程網(wǎng)