centos 6.X 常见的一些安全或效能优化操作,这里记录一些简单的优化专案,高深的先不写。
Centos 6.X 系统优化
一、设定 WordPress 主机名
# vim /etc/sysconfig/network
HOSTNAME=hyq_db
二、关闭 SELinux(个人不建议关闭)
# vim /etc/selinux/config
SELINUX=disabled
# getenforce #检视 selinux 状态
三、清空防火墙并设定规则
# iptables -F #清除防火墙规则
# iptables -L #检视防火墙规则
# iptables -A INPUT -p tcp –dport 22 -j ACCEPT
# iptables -A INPUT -p icmp -j ACCEPT
# iptables -P INPUT DROP
# /etc/init.d/iptables save
四、新增普通使用者并进行 sudo 授权管理
新增使用者
# useradd mike
# echo “123456” | passwd –stdin mike
设定 sudo 方法一
# chmow u+w /etc/sudoers
# vim /etc/sudoers
root ALL=(ALL) ALL
mike ALL=(ALL) ALL
# chmow u-w /etc/sudoers
设定 sudo 方法二
# visudo
root ALL=(ALL) ALL
mike ALL=(ALL) ALL
五、禁用 root 远端登入
# vim /etc/ssh/sshd_config
PermitRootLogin no
PermitEmptyPasswords no #禁止空密码登入
UseDNS no #关闭 DNS 查询
六、关闭不必要开机自启动服务
编写指令码,执行后保留六个开机自启动项。
开机自启动项自己确定
#!/bin/bash
#关闭所有的开机自启动项
sys=`chkconfig –list | awk ‘{print $1}’`
for chk in sys
do
chkconfig $chk off
done
#开启 crond 、 rsyslog 、 sshd 、 network 、 iptables 、 ip6tables 六项开机自启动
list=”crond rsyslog sshd network iptables ip6tables”
for chk in $list
do
chkconfig –level 3 $chk on
done