很久没折腾了。

今天写个买最便宜的VPS(便宜的代价就是VPS非常弱)只跑代理,系统最小化。

这里还是推荐racknerd.com,现在年付只要$10.96。他们的VPS是真便宜,相对它的价格,性能又还不错。

系统推荐FreeBSD的,最小化安装只有10个进程。

htop

很多VPS提供商都有提供FreeBSD系统,但racknerd没有提供,可以写提交服务单要求他们给安装FreeBSD,他们会让我们提供个安装镜像链接,我们只要把官方最新的ISO镜像链接发给客服就OK了。

客服会把FreeBSD的安装镜像挂载,我们只要重启,就能正常安装了,安装完,再把系统启动顺序改成先硬盘后光盘就可以正常进入系统。

如果用其他VPS,他们提供的版本基本上是12.0+的,不是最新的,如果没强迫症也能直接用,也能升级到最新版本。

1.FreeBSD12+升级到最新的FreeBSD14.3

$ freebsd-version #查看当前版本

$freebsd-update -r 14.3-RELEASE upgrade #升级到当前最新版本,目前是14.3

$ freebsd-update install #升级安装

$ reboot #系统重启

$ freebsd-update install #再次更新服务器

$ pkg update #更新包

$ pkg upgrade #安装更新包

$ pkg install vim wget htop #安装必要的软件

这新FreeBSD就更新到最新的14.3版本了。

2.代理服务器端用Hysteria2

Hysteria2设置简单,性能强劲,强力推荐,只自己用,很方便。

先到官网下载最新的for freebsd版

$ wget https://github.com/apernet/hysteria/releases/download/app%2Fv2.6.2/hysteria-freebsd-amd64 #下载目前最新的2.6.2版

$ mv hysteria-freebsd-amd64 hysteria #把文件改名成hysteria

# chmod +x hysteria #让文件可执行

$ mv hysteria /usr/local/bin #将文件移到相应目录

$ sysrc hysteria_enable="YES" #设置开机启动

创建启动脚本,并将脚本放到目录/usr/local/etc/rc.d中。系统默认没有这个脚本,我的脚本如下:

#!/bin/sh

# PROVIDE: hysteria
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add these lines to /etc/rc.conf.local or /etc/rc.conf to enable `hysteria':
#
# hysteria_enable (bool):          Set to "NO" by default.
#                               Set it to "YES" to enable hysteria
# hysteria_config (path):          Set to "/usr/local/etc/hysteria/config.json" by default
#                               Set it to the hysteria server config
# hysteria_logdir (path):            Set to "/var/log/hysteria" by default.
#                               Set it to the directory of hysteria log files
# hysteria_env (str):                Set to "" by default.
#                               Set it to the desired environment variables

. /etc/rc.subr

name="hysteria"
rcvar="${name}_enable"

: ${hysteria_enable="NO"}
: ${hysteria_logdir="/var/log/${name}"}
: ${hysteria_env=""}
: ${hysteria_user="root"}
: ${hysteria_group="wheel"}

pidfile="/var/run/$name.pid"
procname="/usr/local/bin/$name"
command="/usr/sbin/daemon"
command_args="-c -p ${pidfile} /usr/bin/env ${asset_env} ${hysteria_env} ${procname} server -c /usr/local/etc/config.yaml"

start_precmd="hysteria_startprecmd"

hysteria_startprecmd() {
        touch "${pidfile}"
        chown ${hysteria_user}:${hysteria_group} "${pidfile}"
}

load_rc_config "$name"
run_rc_command "$1"

配置config.yaml,将文件放到/usr/local/etc下。

就能正常启动服务了

service hysteria start

最后只要配置下客户端就可以用了。。。

Related content