Linux VPS 系统精简优化实战指南
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/ 相关文章 智能推荐
1
从手动挂载到自动挂载:Autofs 挂载 NFS 的真香体验
虚拟化与运维 如何解决NFS挂载导致系统启动卡死的问题?本文详细分享使用Autofs实现智能自动挂载的实战方案,解决fstab依赖问题,提升系统稳定性与资源利用率。
2
PVE更新CPU微码解决N5105虚拟机死机问题
虚拟化与运维 N5105虚拟机频繁死机怎么办?本文详细讲解在Proxmox VE系统中更新Intel CPU微码至0x24000024的完整步骤,包括自动与手动更新方法,有效解决虚拟机崩溃问题。
3
群晖NAS存储池排序与名称修改指南
NAS私有云 如何调整群晖NAS中存储池的顺序和存储空间名称?本文详细讲解通过SSH命令行修改存储池ID与存储空间命名的方法,解决因硬盘更换导致的乱序问题,适用于NAS私有云用户进行系统优化。
4
群晖DSM卸载Universal Search套件指南
NAS私有云 群晖Universal Search占用系统资源过高怎么办?本文提供通过SSH终端卸载或临时停用SynoFinder套件的完整操作步骤,解决NAS性能瓶颈问题。
5
GhostVM:给 AI Agent 一个完整的 Mac,而不是容器!
虚拟化与运维 介绍 GhostVM——基于 Apple Virtualization.framework 的 macOS 虚拟机工具。支持近原生性能、自包含 bundle、秒级克隆,提供完整的 CLI (vmctl) 覆盖 GUI 功能,适合 AI agent 隔离环境和多项目开发者。
随机文章 随机推荐