Skip to main content

从零开始的服务器搭建纪实

Ven2s...About 6 minCodeServer

Hello World

LuvSia

Server Building

准备工作

VPSDomain
dmitopen in new windowexample.comopen in new windownginxopen in new windowmysqlopen in new windowphpopen in new windowphpmyadminopen in new windowcloudflareopen in new window

更新软件源

apt update

搭建思路

预留一级域名搭建网站给各个应用添加前端网页根路径。

后因部分应用无法添加二级目录(网页根路径),所以这里只能使用添加二级域名的思路,区别各个应用。

再通过添加反向代理,实现分域名访问不同前端应用。

开始搭建

宝塔面板

WorkWeb
宝塔面板btopen in new window

1.使用一键配置工具。
一键脚本集成工具

wget -O box.sh https://raw.githubusercontent.com/BlueSkyXN/SKY-BOX/main/box.sh && chmod +x box.sh && clear && ./box.sh

wget -O install.sh http://io.bt.sy/install/install-ubuntu_6.0.sh && bash install.sh

2.安装nginx-1.21mysql-5.5php-7.4phpmyadmin-5.0四件套

3.添加站点。

WorkDomain
alista.example.comopen in new window正常
宝塔面板b.example.comopen in new window正常
Transmissiont.example.comopen in new window正常
X-UIx.example.comopen in new window正常

4.设置,添加SSL,强制开启https

记录证书路径,证书可以直接在宝塔面板进行更新,或是设置定时任务自动更新;

宝塔面板申请的证书在如下目录:/www/server/panel/vhost/cert/你的域名/ 目录之下。

强制开启https

5.关闭面板安全入户,即删除二级目录

rm -f /www/server/panel/data/admin_path.pl

6.在Cloudflare中解析二级域名b.example.com

7.添加反向代理到b.example.com

代理名称 宝塔面板
目标URL  http://127.0.0.1:8888  发送域名 $host

8.安装docker安装器。

X-UI

WorkWebTools
x-uixuiopen in new windowdockeropen in new window

1.镜像源

enwaiax/x-ui:latest

2.安装运行

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
    -v $PWD/cert/:/root/cert/ \
    --name x-ui --restart=unless-stopped \
    enwaiax/x-ui:latest

3.在Cloudflare中解析二级域名x.example.com

4.添加反向代理到x.example.com

代理名称 x-ui
目标URL  http://127.0.0.1:54321  发送域名 $host

5.配置VMess协议,开启ws,路径/xiya

6.开启CDN加速,在nginx配置文件中添加如下。

location /xiya {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:22513;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 300s;
        # Show realip in v2ray access.log
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

7.开启Cloudflare小云朵,并优选IP。

8.下载优选IPopen in new window ,选出优选IP后,客户端如下配置

+ 填入优选IP
+ 更改端口为443;
+ host设置x.example.com;
+ 开启tls。

9.Surge配置

🇭🇰 VMess = vmess, 104.19.79.223, 443, username=2d285385-836d-4b30-f32c-11cdd637aeed, tls=true, tls13=false, ws=true, ws-path=/xiya, sni=example.com, ws-headers=Host:example.com, skip-cert-verify=0, tfo=false, udp-relay=true

Alist

WorkWebTools
Alistalistopen in new windowdockeropen in new window

1.添加镜像源

xhofe/alist:latest

2.不配置容器,使用代码

docker run -d --restart=always -v /etc/alist:/opt/alist/data -p 5244:5244 --name="alist" xhofe/alist:latest

3.在Cloudflare中解析二级域名a.example.com

4.添加反向代理到a.example.comopen in new window

代理名称 alist
目标URL  http://127.0.0.1:5244  发送域名 $host

Transmission

WorkWebTools
Transmissiontransmissionopen in new windowdockeropen in new window

1.Docker安装

构建镜像

# 克隆仓库
git clone https://github.com/helloxz/docker-transmission.git
# 进入仓库目录
cd docker-transmission
# 构建Docker镜像
docker build -t luvsia:transmission

运行镜像

docker run -d --name="transmission" \
  -e USERNAME=ventus \
  -e PASSWORD=ysw554247430 \
  -p 9091:9091 \
  -p 51413:51413 \
  -p 51413:51413/udp \
  -v /GoogleDrive:/Downloads \
  --restart=always \
  luvsia:transmission

/GoogleDrive:本地下载目录为Rclone mount GoogleDrive中的谷歌云盘目录,自动下载到谷歌云盘,实现无线网盘

2-1.普通安装

安装transmission-daemon

apt-get install transmission-daemon

首先执行一次启动和停止命令,防止配置文件被覆盖

启动

service transmission-daemon start

停止

service transmission-daemon stop

重启

service transmission-daemon restart

修改transmission-daemon配置文件

nano /var/lib/transmission-daemon/info/settings.json
"rpc-host-whitelist": "*",  //域名白名单,*为允许所有
"rpc-host-whitelist-enabled": false, //是否开启白名单,false为否
"rpc-password": "远程登录密码",
"rpc-port": 9091, //远程登录端口
"rpc-username": "远程帐号",
"rpc-whitelist": "*", //ip白名单
"rpc-whitelist-enabled": false,  //是否开启ip白名单,false为否

执行启动命令

service transmission-daemon start
systemctl enable transmission-daemon.service

2-2.transmission web control

获取安装脚本

wget https://github.com/ronggang/transmission-web-control/raw/master/release/install-tr-control-cn.sh

执行安装脚本

bash install-tr-control-cn.sh

3.在Cloudflare中解析二级域名t.example.com

4.添加反向代理到t.example.comopen in new window

代理名称 transmission
目标URL  http://127.0.0.1:9091  发送域名 $host

5.修改默认保存目录/GoogleDrive,启用临时目录/Downloads,记得给!权限!

把`/Downloads`赋予777权限

Rclone

WorkWebTools
Rclonercloneopen in new windowgoogledriveopen in new window

1.安装Rclone

wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh

2.初始化配置

rclone config

3.选择GoogleDrive,剩余操作参考这里open in new window

CMD开启代理

set http_proxy=socks5://127.0.0.1:10808 #端口号为http的socks5实际端口
set https_proxy=socks5://127.0.0.1:10808 #端口号为https的socks5实际端口

4.挂载磁盘

mkdir -p /GoogleDrive
mkdir -p /Downloads

Tips

确认安装了FUSE3

apt install fuse3
rclone mount ventusoon:ventus /GoogleDrive \
 --umask 0000 \
 --default-permissions \
 --allow-non-empty \
 --allow-other \
 --transfers 4 \
 --buffer-size 32M \
 --low-level-retries 200
 --dir-cache-time 12h
 --vfs-read-chunk-size 32M
 --vfs-read-chunk-size-limit 1G

5.配置开机自动挂载

cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
AssertPathIsDirectory=LocalFolder
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount ventusoon:ventus /GoogleDrive \
 --umask 0000 \
 --default-permissions \
 --allow-non-empty \
 --allow-other \
 --buffer-size 32M \
 --dir-cache-time 12h \
 --vfs-read-chunk-size 64M \
 --vfs-read-chunk-size-limit 1G
ExecStop=/bin/fusermount -u LocalFolder
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF

挂载成功后,输入df -h命令即可看到挂载的磁盘

6.常用命令

systemctl start rclone
systemctl enable rclone
systemctl stop rclone
systemctl status rclone

7.Transmission添加rlone挂载在GoogleDrive上的路径

/GoogleDrive

Live-torrent

WorkWebTools
live-torrentlive-torrentopen in new windowdockeropen in new window

1.镜像源

davenchy/live-torrent

2.安装运行

docker run --restart=always --name live-torrent -d -p 8080:8080 davenchy/live-torrent

3.在Cloudflare中解析二级域名live.example.com

4.添加反向代理到live.example.com

代理名称 Live-torrent
目标URL  http://127.0.0.1:8080  发送域名 $host

Cloudflare WARP

WorkWebUse
Cloudflare WARPcloudflareopen in new window使用教程open in new window

功能菜单

bash <(curl -fsSL git.io/warp.sh) menu

WARP WireGuard 双栈全局网络

bash <(curl -fsSL git.io/warp.sh) d

IPv4 网络

bash <(curl -fsSL git.io/warp.sh) 4

IPv6 网络

bash <(curl -fsSL git.io/warp.sh) 6

WARP 官方客户端 SOCKS5 代理

bash <(curl -fsSL git.io/warp.sh) s5

后记

感谢

@guodongxiarenopen in new window
@HostCLiopen in new window
@jinwypopen in new window
@Xhofeopen in new window
@vaxiluopen in new window
@enwaiaxopen in new window
@XIU2open in new window
@helloxzopen in new window
@moeratsopen in new window
@P3TERXopen in new window


Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v2.15.8