-
Notifications
You must be signed in to change notification settings - Fork 0
/
vps.txt
135 lines (103 loc) · 3.2 KB
/
vps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
set up a vps for hosting websites, mail and vpn
# access the server
$ ssh root@ip
# add user
$ adduser tga
# add sudo priviliedge to user
$ usermod -aG sudo tga
# copy ssh key to user
$ rsync --archive --chown=tga:tga ~/.ssh /home/tga
# change to user
$ su - tga
# install packages
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install -y zsh vim make git unzip sqlite3
# clone this repo
$ git clone https://github.com/slmjkdbtl/rc
# init config
$ cd rc && make
# change default shell
$ sudo chsh -s /usr/bin/zsh
$ zsh
$ zplug install
# install bun
$ curl -fsSL https://bun.sh/install | bash
# install caddy
$ sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
$ sudo apt update
$ sudo apt install -y caddy
# start caddy
$ sudo systemctl enable --now caddy
# reload systemd configs files
$ sudo systemctl daemon-reload
# start a service
$ sudo systemctl start space55.xyz
# stop a service
$ sudo systemctl stop space55.xyz
# enable a service to run on startup
$ sudo systemctl enable space55.xyz
# enable a service and run it now
$ sudo systemctl enable --now space55.xyz
# reload config for a service
$ sudo systemctl reload caddy
# check status on a service
$ sudo systemctl status caddy
# view log
$ journalctl -qu space55.xyz
# /etc/systemd/system/space55.xyz.service
[Unit]
Description=space55.xyz
After=network.target
[Service]
Type=simple
User=tga
Environment="PORT=4000"
WorkingDirectory=/home/tga/space55.xyz
StandardError=append:/home/tga/space55.xyz/data/err.log
ExecStart=/bin/sh -l start
Restart=always
StandardOutput=journal
StandardError=journal
StandardInput=null
[Install]
WantedBy=multi-user.target
# /etc/caddy/Caddyfile
space55.xyz {
encode gzip
reverse_proxy localhost:4000
}
# install docker
# https://docs.docker.com/engine/install/ubuntu
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl
$ sudo install -m 0755 -d /etc/apt/keyrings
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
$ sudo chmod a+r /etc/apt/keyrings/docker.asc
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
# install wireguard package
$ apt install wireguard
# generate wireguard keys
$ cd /etc/wireguard
$ wg genkey | private.key | wg pubkey | public.key
$ chmod 700 private.key
# /etc/wireguard/wg0.conf
[Interface]
PrivateKey =
Address = 10.8.0.1/24
[Peer]
AllowedIPs = 0.0.0.0/0
# /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
# get tunnel up
$ wg-quick up wg0
# install mail server packages
$ apt update
$ apt install -y postfix dovecot-imapd spamassassin opendkim