这是我的规格

这是我的规格

我用 Google 搜索了好几天,收集了所有优化建议并进行了尝试。
我的网站点击率不高。
每天的点击率可能只有 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配置文件

我取消选择了许多模块,并使用 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 防病毒软件]

SpamAssasin 已关闭

调整设置下

Default catch-all/default address behavior for new accounts.  This is set to "fail"
All stats programs turned off

我已经安装了 eAccelerator 并检查了 phpinfo 及其运行情况

[WHM 下预包含 VirtualHost]

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 为 800MB 时 mysql 的进程列表

以下是 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 ?

1GB 的内存量很小,但我运行了大约 5 个 wpmu 网站和一个 tikiwiki 网站,占用空间不到 256MB,还玩了一些 PHPCake 和 Ruby on Rails。我还想转移一些 Drupal 网站,但我的内存有点不足。

我还有一个 APC 缓存,但我严格将其用于代码缓存,并将页面和对象缓存保存在磁盘上,尽管我对我的 WPMU 网站使用的是 W3 Total Cache,而不是 Super Cache,我发现后者也相当不错。

我没有在我的 VPS 系统上使用任何面板。我喜欢直接在 Linux 中工作的自由。我为我的电子邮件服务器运行 exim,为 pop3 运行 dovecot。我想设置 python 和 tomcat,因为我有一种 MVC 统一的想法,我想研究一下它是否有潜力。

无论如何,我的 wpmu 网站很小,但我的 VPS 显然只有你的四分之一。仔细想想,我启动系统时注意到的第一件事就是,在我将其连接到 DNS 之前,就有脚本小子和垃圾邮件机器人攻击我的 VPS!有些甚至在进行暴力攻击,所以我设置了一些入侵检测,并将它们放入防火墙几天,其他的则永久保留。我还通过 apache 和 wordpress 插件在网站中安装了很多安全措施,以阻止 sql 插入和垃圾。

我想知道您是否在打开 50 条 Apache 线路的情况下通过 SSL 发起了一些暴力攻击,不过我注意到您提到大概有 15 个并发连接?

运行 top、ps、vmstat、iostat 或任何可用的工具可能会让您了解瓶颈所在。您的分页或扫描速率是否很高?您是否有大量可运行任务?CPU 负载是多少?如果您一直在动态压缩和加密每秒数以万计的内容,那么您的 CPU 负载很容易就会达到最高。

或者您的某个页面在 Digg 上很受欢迎?抱歉。现在已经很晚了,我可能应该睡一觉,因为我到处乱逛,我不知道我是否能找到任何可以给您带来宝贵想法的东西……

谨致问候,丹

相关内容