CentOS精简与优化

CentOS安装完毕后,需要进行的优化步骤。

注意:本文所述的优化,是针对于VPS环境的,桌面环境和独立服务器的CentOS请勿使用本文中的方法进行优化,否则可能导致桌面环境不正常。独立服务器也不要使用本文中的方法去优化,否则会引起异常~

1,删除不必要的软件包

yum remove Deployment_Guide-en-US finger cups-libs cups ypbind
yum remove bluez-libs desktop-file-utils ppp rp-pppoe wireless-tools irda-utils
yum remove sendmail* samba* talk-server finger-server bind* xinetd
yum remove nfs-utils nfs-utils-lib rdate fetchmail eject ksh mkbootdisk mtools
yum remove syslinux tcsh startup-notification talk apmd rmt dump setserial portmap yp-tools
yum groupremove "Mail Server" "Games and Entertainment" "X Window System" "X Software Development" 
yum groupremove "Development Libraries" "Dialup Networking Support" 
yum groupremove "Games and Entertainment" "Sound and Video" "Graphics" "Editors" 
yum groupremove "Text-based Internet" "GNOME Desktop Environment" "GNOME Software Development"

2,升级整个系统

yum update   #更新全部更新
yum clean all     #清理全部缓存的安装文件以节省空间

3,禁用seLinux

sestatus   先执行这一句看看seLinux状态,如果不是disabled,那么执行如下步骤将其禁用
vi /etc/selinux/config 
SELINUX=disabled  禁用SeLinux
SELINUX=enforcing  使用SeLinux

4,停止网卡对ipv6的支持

vi /etc/modprobe.conf   添加如下行到文尾:
alias net-pf-10 off
alias ipv6 off

重启后生效。

5,修改环境变量语言编码,防止出现乱码

vi /etc/profile
找到export PATH ……这一行,在其上面加上一行 LANG=en_US.UTF-8
然后在export PATH ……这一行后面补充一个LANG
source /etc/profile

6,初始化防火墙

touch /etc/sysconfig/iptables
iptables -F
iptables -X
iptables -Z
service iptables save
service iptables restart

7,来个一键优化脚本,自动禁用无用服务,且禁止其开机自启动

#! /bin/bash
service acpid off
service atd stop
service auditd stop
service avahi-daemon stop
service avahi-dnsconfd stop
service bluetooth stop
service conman stop
service cpuspeed stop
service cups stop
service dnsmasq stop
service dund stop
service firstboot stop
service hidd stop
service httpd stop
service ibmasm stop
service ip6tables stop
service irda stop
service kdump stop
service lm_sensors stop
service mcstrans stop
service messagebus stop
service microcode_ctl stop
service netconsole stop
service netfs stop
service netplugd stop
service nfs stop
service nfslock stop
service nscd stop
service ntpd stop
service oddjobd stop

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据