今天整理这个博客,看到了2018年写的在CentOS上装Caddy.时间还真久了呢,7年的时间,收获了很多,也失去了很多. 至少,折腾服务器的时间是少了很多很多了.
周末无聊随便看网页,正好翻到了开发者可以申请免费RHEL的文章. 这可是面向企业收费的Linux呀,一定稳得不行吧,装一个体验体验. (当初换成Debian可能也有CentOS变成RHEL上游的原因?)
不过装RHEL也有一些顾虑,最新的RHEL 10需要CPU支持x86-64-v3了,我的上古垃圾服务器肯定是不支持了,只能装RHEL9. (2032年才EOL,没什么大问题)
下面写一写安装好RHEL之后做的一些设置吧
- 启用BBR. (排第一位的常规操作)
1 2 3 4 5
| cat << EOF > /etc/sysctl.conf net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr EOF sysctl -p
|
激活系统
去dashboard用给出的activation key和命令行执行就可以激活.
设置交换分区
1 2 3 4 5 6 7 8 9 10 11 12
| fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
cat << EOF >> /etc/fstab /swapfile none swap sw 0 0 EOF
|
- 更新系统
- 安装EPEL. (没错,一边想着RHEL稳定,一边把EPEL装上了┐(´д`)┌)
1 2
| subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
|
- 安装docker.
1 2 3 4
| dnf -y install dnf-plugins-core dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin systemctl enable --now docker
|
- 优先IPv4.
1
| echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf
|
- 设置密钥登录
1 2 3 4
| ssh-keygen -t ed25519
mv /root/.ssh/id_ed25519.pub /root/.ssh/authorized_keys
|
修改/etc/ssh/sshd_config
Port
:SSH端口
PermitRootLogin
: prohibit-password
禁止密码登录
修改前可以试一试密钥登录是否正常.
- 系统自动更新
1
| dnf install -y dnf-automatic
|
修改/etc/dnf/automatic.conf
中的apply_updates = yes
1
| systemctl enable --now dnf-automatic.timer
|
- 设置时区
1
| timedatectl set-timezone Asia/Shanghai
|
- 使用DNS over TLS,这里使用
systemd-resolved
. (内存比较足的推荐使用Technitium DNS Server(ノ>ω<)ノ)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| dnf install dnf install systemd-resolved
cat << EOF > /etc/systemd/resolved.conf [Resolve] DNS=1.1.1.1 9.9.9.9 8.8.8.8 FallbackDNS= DNSSEC=yes DNSOverTLS=yes Cache=yes EOF
systemctl enable --now systemd-resolved
cat << EOF > /etc/resolv.conf nameserver 127.0.0.53 EOF
chattr +i /etc/resolv.conf
|
- 一些bash的设置
1 2 3 4 5 6 7 8 9 10 11
| cat << EOF >> ~/.bashrc # 忽略重复命令 export HISTCONTROL=ignoredups:erasedups # 设置命令历史记录的最大条目数 export HISTSIZE=10000 # 设置命令历史记录的最大字节数 export HISTFILESIZE=10000 # 一些替换 alias vi="vim" alias ls="ls --color" EOF
|