我的VPS安装完KLOXO后内存占用最低一直显示是28%左右,无意中看到了一篇KLOXO优化的文章,拿来和大家分享一下。优化完之后内存占用率下降了10%,所以推荐VPS安装KLOXO的站长们都看一下。

首先进入/etc 目录,编辑my.cnf
命令:先cd /etc,再vi my.cnf

在[mysqld]下面加入以下三行:
skip-locking
skip-bdb
skip-innodb

保存之后在重启MYSQL
命令: /sbin/service mysqld restart

在用top看看内存占用时不时降到100M以下了。
作用详解:
使用–skip -locking的MySQL选项避免外部锁定
加载–skip-bdb –skip-innodb参数以避免内存浪费

记得一定要重启MYSQL服务哦

2.设置默认的dns组件为djbdns,在Switch Program中切换。
3.把Apache设置成lighttpd,非技术帝需谨慎。
free结果:
total used free shared buffers cached
Mem: 512 76 435 0 0 0
Swap: 0 0 0

top结果:
top – 22:09:21 up 10:05, 1 user, load average: 0.01, 0.03, 0.00
Tasks: 32 total, 4 running, 28 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 524800k total, 74688k used, 450112k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 15 0 10348 744 624 S 0.0 0.1 0:00.79 init
9735 root 16 0 5908 608 488 S 0.0 0.1 0:00.10 syslogd
9804 root 15 0 62604 1220 656 S 0.0 0.2 0:00.04 sshd
9864 root 18 0 11932 1368 1148 S 0.0 0.3 0:00.00 sh
9898 lxlabs 18 0 5992 1740 664 R 0.0 0.3 0:01.90 kloxo.httpd
10218 root 15 0 20872 1160 576 S 0.0 0.2 0:00.03 crond
10232 root 18 0 46736 816 428 S 0.0 0.2 0:00.00 saslauthd
10234 root 18 0 46736 548 160 S 0.0 0.1 0:00.00 saslauthd
11335 root 18 0 27152 15m 4472 S 0.0 3.0 0:01.01 php
11650 root 18 0 212m 7176 3348 R 0.0 1.4 0:01.79 httpd
11655 apache 18 0 212m 5080 1188 S 0.0 1.0 0:00.01 httpd
16074 root 15 0 21644 928 708 S 0.0 0.2 0:00.00 xinetd
18351 qmails 18 0 10196 544 412 S 0.0 0.1 0:00.00 qmail-send
18371 qmaill 19 0 3796 548 460 S 0.0 0.1 0:00.00 splogger
18372 root 20 0 3816 404 308 S 0.0 0.1 0:00.00 qmail-lspawn
18373 qmailr 18 0 3816 408 308 S 0.0 0.1 0:00.00 qmail-rspawn
18374 qmailq 18 0 3788 400 320 S 0.0 0.1 0:00.00 qmail-clean

登上

用putty登陆你的VPS,执行:

service named stop;
chkconfig named off;
service qmail stop;
chkconfig qmail off;
chkconfig courier-imap off;

其实vps也可以禁用iptables的:

service iptables stop;
chkconfig iptables off;

二,优化mysql:

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
skip-bdb
skip-innodb

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

上面的这个数据库的优化 我没有尝试,我使用了上面第一个真接加入3行代码的方法