我已經用谷歌搜尋了幾天並收集了所有優化建議並進行了嘗試。
我的網站點擊率不高。
每天可能有 100 次點擊[我所有網站的總和]。
這是我的規格
我有 512 MB RAM VPS,可突發 1024 MB。
Centos 5 32-bit & cPanel/WHM
Apache 2.2
MySQL 5.0
PHP 5.3.2
這是我的配置
我有 2 個 WordPressMU 生產站點和 1 個測試站點
我的cnf
我使用 my-medium.cnf 範例開始
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
skip-bdb
skip-innodb
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
#CAPitalZ
thread_cache_size=8
thread_concurrency=4
#query_cache_type=1
#query_cache_limit=1M
query_cache_size=16M
concurrent_insert=2
low_priority_updates=1
max_connections=50
tmp_table_size=16M
max_heap_table_size=16M
join_buffer_size=1M
interactive_timeout=25
wait_timeout=1000
#connect_timout=10 not able to restart mysql
max_connect_errors=10
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
skip-networking
# Disable Federated by default
skip-federated
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
[mysqld_safe]
open_files_limit=8192
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
httpd.conf
我取消選擇了許多模組並使用 WHM 中的 EasyApache 重新編譯。
僅建置以下模組
Deflate
Expires
Fileprotect
Imagemap
MPM Prefork
Version [default]
EAccelerator for PHP
Bcmath
Calendar
CurlSSL [I'm using Curl. But I don't have any https sites]
Expat
GD [for image cropping]
Gettext
Imap
Mbregex [default]
Mbstring [need both Mbregex and Mbstring for utf-8]
Mysql of the system
MySQL "Improved" extension.
Sockets
TTF (FreeType) [I'm using custom font]
Zlib
全域配置下
I only have FollowSymLinks enabled
I Have TraceEnable, ServerSignature, FileETag OFF
ServerTokens ProductOnly
DirectoryIndex Priority has index.php as the first one
我已經刪除了Clamd [Clam Anti-virus]
SpamAssasin 已關閉
在調整設定下
Default catch-all/default address behavior for new accounts. This is set to "fail"
All stats programs turned off
我安裝了 eAccelerator 並檢查了 phpinfo 及其工作情況
[預虛擬主機包含在 WHM 下]
Timeout 20
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 3
MinSpareServers 1
MaxSpareServers 3
StartServers 1
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 4000
ExtendedStatus Off
#ServerType standalone this throws error
HostnameLookups Off
<Directory "/">
AllowOverride None
</Directory>
我的網站需要很長時間才能加載,而 WHM/CPanel 甚至無法加載。 adadaa.com/adadaa.net/kadais.ca/
我的平均記憶體消耗約為 1000 MB! [是的,總是爆發]
消耗最多CPU和記憶體的進程是mysql,
但我也得到了大約15個httpd進程[當它爆發時]
我已經收到來自cpuwatchcheck的警告,說
「在處理時,CPU已達到最大超過6 小時期間,發送此電子郵件時伺服器上的當前負載/正常運行時間線為 07:00:37 到 11:30,0 個用戶,平均負載:14.64、16.79、20.07"
我不知道,我已經多次嘗試切換這些配置值,但似乎沒有任何效果。
請展示一些燈光...謝謝
這是當 RAM 約為 800 MB 時,WHM 目前正在運行的進程
Pid Name File Current Directory Command Line ▾
11758 (httpd)
24235 (mysqld_safe) /bin/bash / /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/us.adadaa.org.pid
32254 (udevd) /sbin/udevd / /sbin/udevd -d
3591 (simpleps) /usr/local/bin/perl /usr/local/cpanel/whostmgr/docroot /usr/bin/perl /scripts/simpleps --html
1393 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
2005 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
2012 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
3399 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
3420 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
3472 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
3493 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
3494 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
3872 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
7418 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
9482 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
9900 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
13466 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
13656 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
13736 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
14226 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15579 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15623 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15685 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15808 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15814 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
15919 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
16156 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
17526 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
17848 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
18159 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
19821 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
19830 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
19962 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
19980 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
19981 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
20378 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
21595 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
22513 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
23960 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
23965 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
25862 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
26305 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
26339 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
26472 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
27890 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
28600 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
29712 (httpd) /usr/local/apache/bin/httpd / /usr/local/apache/bin/httpd -k start -DSSL
30478 (httpd) /usr/local/apache/bin/httpd /home/ada/public_html /usr/local/apache/bin/httpd -k start -DSSL
1408 (leechprotect) /usr/local/bin/perl /usr/local/cpanel/bin /usr/local/cpanel/bin/leechprotect
1380 (dovecot) /usr/sbin/dovecot /var/run/dovecot /usr/sbin/dovecot
1368 (exim) /usr/sbin/exim /var/spool/exim /usr/sbin/exim -bd -q180m
24275 (mysqld) /usr/sbin/mysqld /var/lib/mysql /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/us.adadaa.org.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock
32657 (named) /usr/sbin/named /var/named /usr/sbin/named -u named
1868 (portsentry) /usr/sbin/portsentry / /usr/sbin/portsentry -tcp
1411 (pure-authd) /usr/sbin/pure-authd / /usr/sbin/pure-authd -s /var/run/ftpd.sock -r /usr/sbin/pureauth
1844 (saslauthd) /usr/sbin/saslauthd /var/run/saslauthd /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
1845 (saslauthd) /usr/sbin/saslauthd /var/run/saslauthd /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
11622 (sshd) /usr/sbin/sshd / /usr/sbin/sshd
1668 (cpanellogd) /usr/local/bin/perl / cpanellogd - sleeping for logs
1645 (cpsrvd-ssl) /usr/local/cpanel/cpsrvd-ssl /usr/local/cpanel/base cpsrvd - waiting for connections
1422 (crond) /usr/sbin/crond /var/spool crond
1381 (dovecot-auth) /usr/libexec/dovecot/dovecot-auth /var/run/dovecot dovecot-auth
1397 (imap-login) /usr/libexec/dovecot/imap-login /var/run/dovecot/login imap-login
1398 (imap-login) /usr/libexec/dovecot/imap-login /var/run/dovecot/login imap-login
1 (init) /sbin/init / init [3]
1395 (pop3-login) /usr/libexec/dovecot/pop3-login /var/run/dovecot/login pop3-login
1396 (pop3-login) /usr/libexec/dovecot/pop3-login /var/run/dovecot/login pop3-login
1409 (pure-ftpd) /usr/sbin/pure-ftpd / pure-ftpd (SERVER)
1592 (queueprocd) /usr/local/bin/perl / queueprocd - wait to process a task
32645 (syslogd) /sbin/syslogd / syslogd -m 0
1618 (tailwatchd) /usr/local/bin/perl / tailwatchd
3589 (whostmgr) /usr/local/cpanel/whostmgr/bin/whostmgr /usr/local/cpanel/whostmgr/docroot whostmgr - simpleps ./simpleps
3520 (cpsrvd-ssl) /usr/local/cpanel/cpsrvd-ssl /usr/local/cpanel/whostmgr/docroot whostmgrd - serving 207.219.51.3
3525 (cpsrvd-ssl) /usr/local/cpanel/cpsrvd-ssl /usr/local/cpanel/whostmgr/docroot whostmgrd - serving 207.219.51.3
32690 (xinetd) /usr/sbin/xinetd / xinetd -stayalive -pidfile /var/run/xinetd.pid
===============
這是 RAM 使用量約為 800 MB 時的當前 CPU 使用率
Pid Owner Priority Cpu % Mem % ▴ Command
25862 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.6 7.5
26305 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.3 6.5
30478 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 6.2
14226 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 6.1
28600 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 6.0
24275 mysql 0 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/us.adadaa.org.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock
30.6 5.8
19980 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 3.2
13656 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 2.9
15685 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
1.6 2.9
2005 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.8
20378 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.8
15579 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.8
18159 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.6 2.8
27890 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.7
22513 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.7
26339 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.4 2.7
13466 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.4 2.7
3872 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.6
15623 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.6
17526 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.5
7418 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.5
23960 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 2.5
13914 root 0 whostmgr2 - top ./top
0.2 2.5
12035 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.3 2.5
21595 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.3 2.5
13736 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.4
16156 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.4
15808 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.4
13557 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.6 2.4
3493 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.3
23965 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 2.3
9900 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.3
19962 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.2 2.3
12026 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.4 2.1
19821 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 2.0
15919 nobody 0 /usr/local/apache/bin/httpd -k start -DSSL
0.1 2.0
1393 root 0 /usr/local/apache/bin/httpd -k start -DSSL
0.0 1.0
13689 root 0 whostmgrd - serving 207.219.51.3
0.0 0.9
13898 root 0 whostmgrd - serving 207.219.51.3
0.0 0.8
1645 root 0 cpsrvd - waiting for connections
0.0 0.7
1408 root 0 /usr/local/cpanel/bin/leechprotect
0.0 0.4
32657 named 0 /usr/sbin/named -u named
0.0 0.3
1592 root 0 queueprocd - wait to process a task
0.0 0.3
13698 root 0 tailwatchd
0.0 0.3
1618 root 0 tailwatchd
0.0 0.2
1668 root 18 cpanellogd - sleeping for logs
0.0 0.1
24235 root 0 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/us.adadaa.org.pid
0.0 0.1
1422 root 0 crond
0.0 0.1
1411 root 0 /usr/sbin/pure-authd -s /var/run/ftpd.sock -r /usr/sbin/pureauth
0.0 0.1
1409 root 0 pure-ftpd (SERVER)
0.0 0.1
1398 dovecot 0 imap-login
0.0 0.1
1397 dovecot 0 imap-login
0.0 0.1
1396 dovecot 0 pop3-login
0.0 0.1
1395 dovecot 0 pop3-login
0.0 0.1
1368 mailnull 0 /usr/sbin/exim -bd -q180m
0.0 0.1
11622 root 0 /usr/sbin/sshd
0.0 0.1
32690 root 0 xinetd -stayalive -pidfile /var/run/xinetd.pid
0.0 0.0
32645 root 0 syslogd -m 0
0.0 0.0
32254 root -4 /sbin/udevd -d
0.0 0.0
1868 root 0 /usr/sbin/portsentry -tcp
0.0 0.0
1845 root 0 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
0.0 0.0
1844 root 0 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
0.0 0.0
1381 root 0 dovecot-auth
0.0 0.0
1380 root 0 /usr/sbin/dovecot
0.0 0.0
14050 root 0 /bin/ps -ewwo pid,user,nice,pmem,pcpu,command
0.0 0.0
1 root 0 init [3]
0.0 0.0
答案1
我想知道您的日誌檔案中是否顯示了任何有趣的內容(可能在 /var/log/httpd 下?
看起來就像您將 .htaccess 中的內容移至 /etc/httpd/conf 檔案中,這可以幫助防止 apache 摸索 .htaccess 檔案的目錄。
您可以透過 ssh 或 putty 以某種方式登入並取得可以執行 top 的命令 shell 嗎?
一份演出佔用的記憶體很小,但我正在運行大約 5 個 wpmu 站點和一個 256meg 下的 tikiwiki 站點,並使用 PHPCake 和 Ruby on Rails 進行一些操作。我正在考慮轉移我擁有的一些 Drupal 站點,但我的記憶體有點不足。
我也有一個 APC 緩存,但我嚴格將其用於程式碼緩存,並將頁面和物件快取保留在磁碟上,儘管我為 WPMU 網站使用 W3 Total Cache,而不是 Super Cache,我也發現 Super Cache 相當不錯。
我的 VPS 系統上沒有使用任何面板。我喜歡直接在 Linux 中工作的自由。我正在為我的電子郵件伺服器運行 exim,為 pop3 運行 dovecot。我想設定 python 和 tomcat,並且我有一個 MVC 統一的想法,我想研究一下它是否是一個有潛力的想法。
無論如何,我的 wpmu 網站很小,但我的 VPS 顯然只有你的四分之一。想想看,在啟動系統時我注意到的第一件事是,在我將 VPS 部署到 DNS 之前,腳本小子和垃圾郵件機器人就已經攻擊了我的 VPS!有些人正在進行一些暴力攻擊,所以我設置了一些入侵檢測並將它們放入防火牆幾天,而其他人則是永久的。我還透過 apache 和 WordPress 外掛程式在網站中安裝了許多安全措施,以阻止 sql 插入和垃圾。
我想知道您是否在打開 50 個 apache 線路的情況下通過 SSL 進行了一些暴力攻擊,儘管我注意到您提到可能有大約 15 個並發連接?
執行 top、ps、vmstat、iostat 或任何可用的命令可能能夠讓您了解瓶頸所在。您的尋呼或掃描速率是否很高?您有大量的可運行程式嗎? CPU 負載是多少?如果您一直在動態地每秒壓縮和加密無數的數據,您的 CPU 負載將很容易達到極高的水平。
或者也許您的某個頁面在 Digg 上變得很受歡迎?對不起。已經很晚了,我可能應該睡一會兒了,因為我到處閒逛,我不知道我是否偶然發現了任何可能給你任何有價值的想法的東西......
最好的問候,丹