1.关闭firewalld防火墙和selinux
...
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/sysconfig/selinux
setenforce 0
...
2.配置iptables共享上网
3.优化字符编码
...
echo export LANG=en_US.UTF-8 >> /etc/profile
source /etc/profile
...
4.配置yum源,安装需要的软件
...
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install lrzsz systat tree vim nmap unzip dos2unix nc lsof iptables -y
...
5.时钟优化
...
yum -y install ntpdate.x86_64 && ntpdate time1.aliyun.com
...
6.修改文件资源的限制
...
tail -4 /etc/security/limits.conf
soft nofile 65535
hard nofile 65535
soft noproc 65535
hard noproc 65535
...
7.优化ssh连接,(也可以修改端口,不过要注意防火墙配置了)
...
vi /etc/ssh/sshd_config
关闭root用户登录的功能
79行 GSSAPIAuthentication no
屏蔽DNS查询功能
115行 UseDNS no
...
8.设置自己的主机名,关增加到hosts文件中
...
hostnamectl set-hostname 主机名
echo 主机名 IP地址 >> /etc/hosts
...