
Linux 安装指南
活用 Linux 扩展库可以提升日常运维效率,是 Linux 部署、运维的奥义。
Brew
安装
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
# Ubuntu 需要的配套编译工具
sudo apt-get install build-essential
常用路径
EL 5
扩展库
# EPEL (Extra Packages for Enterprise Linux) EL5 库。
rpm -Uvh http://archives.fedoraproject.org/pub/archive/epel/5/x86_64/epel-release-5-4.noarch.rpm
# 查看 EPEL 库提供内容
yum --disablerepo="*" --enablerepo="epel" list available
# 第三方 PHP 库,php54w 和 php55w
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
# Shibboleth EL5 库。
wget http://download.opensuse.org/repositories/security://shibboleth/RHEL_5/security:shibboleth.repo -O /etc/yum.repos.d/shibboleth.repo
# 又一个第三方 PHP 库,remi 替换 php 为 5.4,替换默认 MySQL 为 5.5.54 版本
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-5.rpm
# 查看 remi 库提供内容
yum --disablerepo="*" --enablerepo="remi" list available
# vmware-tools 安装库
rpm -Uvh https://packages.vmware.com/tools/releases/latest/repos/vmware-tools-repo-RHEL5-10.3.21-1.el5.x86_64.rpm
扩展库安装后检查具体内容,确认是否已是激活状态:
EL 7
Enterprise 7 的安装程序叫 Anaconda Installer。
装机必做
# 快速 Yum 源镜像,大多默认已安装。
sudo yum -y install yum-plugin-fastestmirror
# 安装 ifconfig。
sudo yum -y install net-tools
# 禁用防火墙
sudo systemctl disable firewalld
# 安装必要工具
sudo yum install vim
# 升级系统补丁
sudo yum makecache
sudo yum update
nmtui # 配置网卡。
ip addr # 没有 ifconfig 时,确认本机网卡及 IP 地址。
# 设置网卡随机启动
vim /etc/sysconfig/network-scripts/ifcfg-ens33
ONBOOT=yes
扩展库
# Fedora's Extra Packages for Enterprise Linux (EPEL)
sudo yum -y install epel-release
sudo yum --enablerepo=extras install centos-release-scl
curl 'https://setup.ius.io/' -o setup-ius.sh # IUS Community Project 源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm # 附加 PHP 版本。
# Driver
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
# vim、zsh
yum install https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
# PHP
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Git
yum install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
OpenSSH 升级
rpm -ivh http://mirrors3.crpm.cn/openssh/x86_64/Packages/openssh-8.6p1-1.el7.centos.x86_64.rpm
rpm -ivh http://mirrors3.crpm.cn/openssh/x86_64/Packages/openssh-clients-8.6p1-1.el7.centos.x86_64.rpm
rpm -ivh http://mirrors3.crpm.cn/openssh/x86_64/Packages/openssh-server-8.6p1-1.el7.centos.x86_64.rpm
EL 9
# Extra Packages for Enterprise Linux (EPEL)
dnf config-manager --set-enabled crb
dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
# SSH 支持 rsa 密钥
update-crypto-policies --set LEGACY
# 确认 Patch 后是否需要重启
needs-restarting -r; echo $?
Ubuntu
Ubuntu EFI 安装
EFI 安装 Ubuntu,需要先在 BIOS 中启用 EFI 模式,然后用 EFI 模式启动 Ubuntu 安装 USB。戴尔机器可以在启动时按 F12 功能键调出One-time Boot Menu 来手动选择安装媒介的引导模式。如果机器原来安装过 Windows 系统,还需要在 BIOS 中禁用 FastBoot 和 Secure Boot。
EFI 启动模式下的系统使用磁盘上 EFI 目录下的 .efi 文件引导。BIOS 里设置启动模式为 EFI 后一般会自动扫描得到所有启动入口,如果启动入口没有自动生成,则需要在 BOIS 里浏览目录,找到 .efi 文件,手动生成启动入口。
常用 APT
扩展库
# 添加 add-apt-repository 支持
sudo apt-get install software-properties-common
# Git
sudo add-apt-repository ppa:git-core/ppa
# PHP 7.0+
sudo add-apt-repository ppa:ondrej/php
# Nginx
sudo add-apt-repository ppa:ondrej/nginx
局域网优化
局域网中可以通过以下配置使用 hostname.local 远程登录 Linux 系统。
CentOS 7
sudo service firewalld stop
sudo systemctl disable firewalld
sudo yum -y install epel-release
sudo yum -y install nss-mdns avahi-daemon
CentOS 8
sudo service firewalld stop
sudo systemctl disable firewalld
sudo yum -y install epel-release
sudo yum -y install nss-mdns avahi
sudo systemctl enable avahi-daemon
Ubuntu 18.04/20.04
apt install avahi-daemon
apt install nmbd
中文支持
Ubuntu 16.04-20.04
# 文件系统 UTF-8 及其他多字节编码支持
sudo apt install linux-modules-extra-$(uname -r)
sudo apt install fonts-wqy-microhei