virtualmin要多少内存,一般来说是200M以上?如何减少webmin的内存占用?经过测试,内存大户是mysql和apache。
对于大部分网站来说,可以把mysql的innodb和bdb禁止,这样内存一下可以给webmin节约100M出来。
方法如下:
[[email protected] ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
skip-innodb
skip-bdb
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[[email protected] ~]# free -m 停止mysql之前的内存355
total used free shared buffers cached
Mem: 512 355 156 0 0 0
-/+ buffers/cache: 355 156
Swap: 0 0 0
[[email protected] ~]# service mysqld stop
Stopping MySQL: [ OK ]
[[email protected] ~]# ps -ef | grep mysql
root 11765 25927 0 19:30 pts/0 00:00:00 grep mysql
[[email protected] ~]# free -m 停止mysql之后的内存228
total used free shared buffers cached
Mem: 512 228 283 0 0 0
-/+ buffers/cache: 228 283
Swap: 0 0 0
[[email protected] ~]# service mysqld start
Starting MySQL: [ OK ]
[[email protected] ~]# free -m 修改参数后启动mysql之后的内存249
total used free shared buffers cached
Mem: 512 249 262 0 0 0
-/+ buffers/cache: 249 262
Swap: 0 0 0
很明显,增加了skip-innodb 和 skip-bdb 参数后,重启mysql,只需要20多M的内存,比修改参数前节约了100M内存。这对于一个512M的vps来说,可谓功劳巨大!
优化apache,一般来说,减少不必要的模块,是减少apache内存占用的最主要方式。如果你的网站访问量很小,那么可以修改httpd.conf,如下,减少httpd进程:
MaxSpareServers 1
MinSpareServers 1
StartServers 1