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
service pand stop
service pcscd stop
service portmap stop
service psacct stop
service rdisc stop
service restorecond stop
service rpcgssd stop
service rpcidmapd stop
service rpcsvcgssd stop
service saslauthd stop
service sendmail stop
service setroubleshoot stop
service smb stop
service vncserver stop
service winbind stop
service wpa_supplicant stop
service xfs stop
service ypbind stop
service yum-updatesd stop
chkconfig acpid off
chkconfig atd off
chkconfig auditd off
chkconfig avahi-daemon off
chkconfig avahi-dnsconfd off
chkconfig bluetooth off
chkconfig conman off
chkconfig cpuspeed off
chkconfig cups off
chkconfig dnsmasq off
chkconfig dund off
chkconfig firstboot off
chkconfig hidd off
chkconfig httpd off
chkconfig ibmasm off
chkconfig ip6tables off
chkconfig irda off
chkconfig kdump off
chkconfig lm_sensors off
chkconfig mcstrans off
chkconfig messagebus off
chkconfig microcode_ctl off
chkconfig netconsole off
chkconfig netfs off
chkconfig netplugd off
chkconfig nfs off
chkconfig nfslock off
chkconfig nscd off
chkconfig ntpd off
chkconfig oddjobd off
chkconfig pand off
chkconfig pcscd off
chkconfig portmap off
chkconfig psacct off
chkconfig rdisc off
chkconfig restorecond off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig rpcsvcgssd off
chkconfig saslauthd off
chkconfig sendmail off
chkconfig setroubleshoot off
chkconfig smb off
chkconfig vncserver off
chkconfig winbind off
chkconfig wpa_supplicant off
chkconfig xfs off
chkconfig ypbind off
chkconfig yum-updatesd off

CentOS精简与优化》上有4条评论

  1. 在我的樱花vps上试了一下 恩 只节约了100MB的空间
    然后 由于一键优化脚本禁用了sendmail 导致我vps现在不能发邮件了。。。

      • 可以,我买了两个月的樱花vps 最低配的那款(1GB RAM),用来折腾+测试,若樱花真的不错,就让我舅舅给我买个年付的吧

        我这樱花还剩一个半月的使用期,你想折腾就拿去用,也帮我测试测试哈哈,联系方式就是这个邮箱

发表评论

电子邮件地址不会被公开。