Pixiv - KiraraShss
902 字
5 分钟
Linux VPS 系统精简优化实战指南
说明: 在安装Linux系统前我们需要顾虑到电脑硬件性能,选择最小化安装非常有必要,毕竟服务器资源一定的情况下,系统只会日益臃肿慢慢开始拖慢所有服务,这些因素在我们安装系统前就应该考虑的,分析哪些是服务器必需和非必需从而尽可能的精简系统。

提示: 请在刚装好的系统中执行操作,而不是在已经运行网站的服务器中优化机器,以免出现机器问题。
Debian系统精简优化
升级Debian系统
apt-get update&&apt-get upgrade移除多余的软件
apt-get -y purge apache2-* bind9-* xinetd samba-* nscd-* portmap sendmail-* sasl2-bin对于这些被移除软件的说明:
apache2-* //apache服务器,一般我们自己会用一键安装包安装bind9-* //我们不需要用VPS搭建DNS,所以去掉xinetd //xinetd是服务守护进程samba-* //samba能让linux使用windows共享功能,不需要nscd-* //DNS缓存软件,同bind9,不需要portmap //端口转发,一般Web服务器不需要sendmail-* //发送邮件用,如果有需要保留sasl2-bin //一个权限程序,占用资源,删除删除多余组件
apt-get -y purge lynx memtester unixodbc python-* odbcinst-* sudo tcpdump ttf-*清理缓存文件
apt-get autoremove && apt-get clean通过上述4步,就可以完成对debian系统的精简优化。
CentOS 系统精简优化
删除不必要的自带软件包
yum remove Deployment_Guide-en-US finger cups-libs cups ypbindyum remove bluez-libs desktop-file-utils ppp rp-pppoe wireless-tools irda-utilsyum remove sendmail* samba* talk-server finger-server bind* xinetdyum remove nfs-utils nfs-utils-lib rdate fetchmail eject ksh mkbootdisk mtoolsyum remove syslinux tcsh startup-notification talk apmd rmt dump setserial portmap yp-toolsyum 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"升级centos系统
yum update #更新系统yum clean all #清理全部缓存文件禁用seLinux
sestatus #先执行看seLinux状态,如果不是disabled,就需要执行下面步骤,否则不要执行vi /etc/selinux/configSELINUX=disabled #禁用SeLinuxSELINUX=enforcing #使用SeLinux禁止IPV6(执行后需要reboot重启)
vi /etc/modprobe.conf #打开文件,把下面两行加到最后alias net-pf-10 offalias ipv6 off初始化防火墙
touch /etc/sysconfig/iptablesiptables -Fiptables -Xiptables -Zservice iptables saveservice iptables restart禁止无用服务
#! /bin/bashservice acpid offservice atd stopservice auditd stopservice avahi-daemon stopservice avahi-dnsconfd stopservice bluetooth stopservice conman stopservice cpuspeed stopservice cups stopservice dnsmasq stopservice dund stopservice firstboot stopservice hidd stopservice httpd stopservice ibmasm stopservice ip6tables stopservice irda stopservice kdump stopservice lm_sensors stopservice mcstrans stopservice messagebus stopservice microcode_ctl stopservice netconsole stopservice netfs stopservice netplugd stopservice nfs stopservice nfslock stopservice nscd stopservice ntpd stopservice oddjobd stopservice pand stopservice pcscd stopservice portmap stopservice psacct stopservice rdisc stopservice restorecond stopservice rpcgssd stopservice rpcidmapd stopservice rpcsvcgssd stopservice saslauthd stopservice sendmail stopservice setroubleshoot stopservice smb stopservice vncserver stopservice winbind stopservice wpa_supplicant stopservice xfs stopservice ypbind stopservice yum-updatesd stopchkconfig acpid offchkconfig atd offchkconfig auditd offchkconfig avahi-daemon offchkconfig avahi-dnsconfd offchkconfig bluetooth offchkconfig conman offchkconfig cpuspeed offchkconfig cups offchkconfig dnsmasq offchkconfig dund offchkconfig firstboot offchkconfig hidd offchkconfig httpd offchkconfig ibmasm offchkconfig ip6tables offchkconfig irda offchkconfig kdump offchkconfig lm_sensors offchkconfig mcstrans offchkconfig messagebus offchkconfig microcode_ctl offchkconfig netconsole offchkconfig netfs offchkconfig netplugd offchkconfig nfs offchkconfig nfslock offchkconfig nscd offchkconfig ntpd offchkconfig oddjobd offchkconfig pand offchkconfig pcscd offchkconfig portmap offchkconfig psacct offchkconfig rdisc offchkconfig restorecond offchkconfig rpcgssd offchkconfig rpcidmapd offchkconfig rpcsvcgssd offchkconfig saslauthd offchkconfig sendmail offchkconfig setroubleshoot offchkconfig smb offchkconfig vncserver offchkconfig winbind offchkconfig wpa_supplicant offchkconfig xfs offchkconfig ypbind offchkconfig yum-updatesd off这样通过上述6步骤,就可以完成对centos精简和优化。
推荐文章
基于标签匹配 · 智能推荐支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!
Linux VPS 系统精简优化实战指南
https://blog.moewah.com/posts/2407/
喵斯基部落