19
2022
07

新VPS服务器(debian系统)整备

一、必要操作

1、用passwd命令修改密码


2、打开sshd_config文件,位于/etc/ssh/sshd_config /etc/ssh/下,把SSH端口有默认的22改成四位数

Port 22

#AddressFamily any

#ListenAddress 0.0.0.0

#ListenAddress ::


3、换源(debian11)

纯命令方式换源

cat > /etc/apt/sources.list << EOF
deb http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free
deb-src http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free
EOF

apt update   # 更新源列表


国外服务器

deb http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free
deb-src http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free

国内服务器

deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free


打开 /etc/apt/sources.list文件,把下面蓝色部分全部复制粘贴替换掉里面的所有几个字

deb http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-updates main contrib non-free
deb http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb-src http://mirrors.xtom.com/debian/ bullseye-backports main contrib non-free
deb http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free

deb-src http://mirrors.xtom.com/debian-security/ bullseye-security main contrib non-free

deb http://mirrors.linode.com/debian/ bullseye main contrib non-free

deb-src http://mirrors.linode.com/debian/ bullseye main contrib non-free

deb http://mirrors.linode.com/debian/ bullseye-updates main contrib non-free

deb-src http://mirrors.linode.com/debian/ bullseye-updates main contrib non-free

deb http://mirrors.linode.com/debian/ bullseye-backports main contrib non-free

deb-src http://mirrors.linode.com/debian/ bullseye-backports main contrib non-free

deb http://mirrors.linode.com/debian-security/ bullseye-security main contrib non-free

deb-src http://mirrors.linode.com/debian-security/ bullseye-security main contrib non-free

或国内源(中科大)

deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free

deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free

deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free

deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free

deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free


apt update   # 更新源列表


4、更新系统及安装wget、cul等常用软件

apt install -y sudo -y wget -y curl -y fuse -y mtr -y socat -y vim -y zip -y unzip   #批量安装常用软件命令,注意-y一定写在软件名之前

apt update -y && apt upgrade -y && reboot   #更新系统并重启


三、可选操作

1、安装BBR加速(就是爱生活脚本)

wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh

debian11自带BBR内核,选4就可以启动BBR加速内核。

2、设置虚拟内存

wget https://www.moerats.com/usr/shell/swap.sh && bash swap.sh   #设置虚拟内存,建议为物理内存的两倍

如果VPS是1G内存,就写2000,如果是2G内存,就写4000,实际上是把硬盘空间拿来当内存。



« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。