n/programu/runoneall · 10 个月前
注册 登录
n/program · 10 个月前 · 已编辑 · 266 次浏览
u/runoneall王者

随迟但到,portlink 使用

感谢 @yoursunny 对 portlink 的建议,部分已在 Commits on Jan 9, 2026 中提交

portlink 使用文档

本文档适用于基于二进制文件直接部署的场景。


一、下载与安装

1. 获取最新版本

portlink 通过 GitHub Action 自动构建。建议前往 Releases 页面 获取最新版本链接。

2. Linux amd64 一键安装

此命令包含了创建目录、下载、赋权并移动到系统路径的逻辑:

# 下载二进制文件
curl -L -o portlink-linux-amd64 https://github.com/runoneall/portlink/releases/download/better-arg/portlink-linux-amd64

# 安装至系统路径
chmod +x portlink-linux-amd64
mv portlink-linux-amd64 /usr/local/bin/portlink

# 验证安装
portlink --version

3. 重装/更新说明

更新前建议先停止服务:

# systemd (Ubuntu/Debian)
systemctl stop portlink || true
# OpenRC (Alpine)
rc-service portlink stop || true

rm -f /usr/local/bin/portlink


二、运行方式

直接启动(测试用):

portlink --server

注意:直接运行时建议配合 nohup 或 screen,生产环境请使用下文的自启服务。


三、开机自启

1. Debian / Ubuntu / CentOS (systemd)

A. 创建服务文件

cat <<EOF > /etc/systemd/system/portlink.service
[Unit]
Description=portlink service
After=network.target network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/portlink --server
Restart=on-failure
RestartSec=5s
# 提升最大文件句柄数,防止高并发连接受限
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target
EOF

B. 管理命令

systemctl daemon-reload
systemctl enable portlink
systemctl start portlink

# 查看状态与实时日志
systemctl status portlink
journalctl -u portlink -f


2. Alpine Linux (OpenRC)

A. 创建服务脚本

cat <<EOF > /etc/init.d/portlink
#!/sbin/openrc-run

name="portlink"
description="portlink service"
command="/usr/local/bin/portlink"
command_args="--server"
command_background=true
pidfile="/run/\${RC_SVCNAME}.pid"
# 日志记录以便排错
output_log="/var/log/portlink.log"
error_log="/var/log/portlink.err"

depend() {
    need net
}
EOF

chmod +x /etc/init.d/portlink

B. 管理命令

rc-update add portlink default
rc-service portlink start

# 查看状态
rc-service portlink status


四、卸载

1. 停止并移除服务

Debian / Ubuntu:

systemctl stop portlink
systemctl disable portlink
rm -f /etc/systemd/system/portlink.service
systemctl daemon-reload

Alpine Linux:

rc-service portlink stop
rc-update del portlink default
rm -f /etc/init.d/portlink

2. 删除二进制文件

rm -f /usr/local/bin/portlink


AI真是太好用了你知道吗()

6
11
登录后参与讨论。
海外原生IP VPS,稳定访问全球网络

还在为IP不纯、平台风控、频繁验证而烦恼? 丽萨主机海外原生IP VPS,双ISP住宅IP,覆盖美国、香港、日本、新加坡、台湾、德国、越南、英国等热门地区,适合跨境电商、社媒运营、AI工具、流媒体及海外业务使用。

lisahost.com 了解更多

11 条回复

排序
  1. Giulio 10 个月前

    不明觉厉

    1
  2. keale 🎧 钻石 3 YEARS 10 个月前

    看来来很厉害,点赞

    0
  3. azhaoyihao 荣耀 水王 10 个月前

    感谢大佬的教程!

    0
  4. weichengi 黄金 10 个月前

    学习下

    0
  5. Mio 黄金 2 YEARS 10 个月前

    感谢教程

    0
  6. ciallo 黄金 10 个月前

    感谢大佬分享教程

    0
  7. lun 黄金 10 个月前

    感谢分享

    0
  8. kurom 黄金 2 YEARS 10 个月前

    支持技术贴

    0
  9. sdcfre 钻石 3 YEARS 10 个月前

    学学

    0
  10. cs9u 钻石 钻石会员 10 个月前

    写了那么多原来是科学上网的

    0
  11. Undertook 黄金 10 个月前

    支持一下

    0