0%

VPS 初始化配置

双十一结束了,买了好多服务器

前言

经历了 CentOS、Ubuntu 之后,我选择了 Debian 作为自己常用的服务器系统,同时也奉劝大家弃用老旧的操作系统。

(Optional) 国内源

如果服务器在国内,需要针对性的进行源更换。一般选用清华源,云服务器则选用云供应商源

如果无法拉取 https 源,则先使用默认的 http 源安装 apt-transport-https

sources.list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# aliyun Debian 9.x (stretch)
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
# Tsinghua Debian 10.x (Buster)
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

Install basic packages

1
2
3
4
5
6
7
8
9
10
apt update
apt install zsh git curl wget htop tmux axel screen build-essential cmake m4 make automake autoconf man-db
# pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
# php-composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

SSH Optimization

下面分别是服务端和客户端的配置,增加心跳检测

/etd/ssh/sshd_conf
1
2
ClientAliveInterval 60
ClientAliveCountMax 3
/etc/ssh/ssh_conf
1
2
TCPKeepAlive yes
ServerAliveInterval 300

SS Backend (discard)

From NimaQu/shadowsocks -> manyuser branch

1
2
3
4
5
6
git clone -b manyuser https://github.com/NimaQu/shadowsocks
cd shadowsocks
pip install -r requirements.txt
cp apiconfig.py userapiconfig.py
cp config.json user-config.json
vim userapiconfig.py

V2Ray

注意记录屏幕输出中的随机端口号和UUID

1
bash <(curl -L -s https://install.direct/go.sh)

Oh-My-Zsh

1
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

vnstat (compiled)

  1. Download the source code
  2. Install dependencies
    1
    apt install libsqlite3-dev libgd-dev
  3. Compile and Install
    1
    2
    ./configure --prefix=/usr --sysconfdir=/etc
    make && make install
  4. Add the service
    1
    2
    3
    4
    vnstatd -d
    cp -v examples/systemd/vnstat.service /etc/systemd/system/
    systemctl enable vnstat
    systemctl start vnstat

未完待续

Buy me a coffee, encourage me keep writing.