Sing-box使用说明
将 sing-box
可执行文件移动到 /usr/local/bin/
目录:
sudo mv sing-box /usr/local/bin/
赋予 sing-box
可执行权限
sudo chmod +x /usr/local/bin/sing-box
确认安装成功:
sing-box version
创建 Sing-box 配置目录:
sudo mkdir -p /etc/sing-box
创建并编辑 config.json
文件:
sudo nano /etc/sing-box/config.json
测试直接运行 Sing-box:
sing-box run -c /etc/sing-box/config.json
设置开机自启
如果你希望 Sing-box 在 Ubuntu 启动时自动运行,可以创建一个 systemd
服务。
创建 systemd
单元文件:
sudo nano /etc/systemd/system/sing-box.service
写入以下内容:
[Unit]
Description=Sing-box Service
After=network.target
[Service]
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
Restart=always
User=nobody
Group=nogroup
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target
保存并退出。
启动并启用服务
重新加载 systemd
:
sudo systemctl daemon-reload
启动 Sing-box:
sudo systemctl start sing-box
设置开机自启:
sudo systemctl enable sing-box
检查运行状态:
sudo systemctl status sing-box
如果成功运行,会看到 active (running)
状态。
修改正在运行的 Sing-box 配置并让其生效的步骤如下:
1. 编辑配置文件
找到你的 Sing-box 配置文件,通常路径是:
/etc/sing-box/config.json
或者你之前保存配置的路径。
使用编辑器打开配置文件:
sudo nano /etc/sing-box/config.json
进行所需的修改。
2. 检查配置文件语法
修改完成后,先检查配置文件是否语法正确,避免错误导致服务无法启动:
sing-box check -c /etc/sing-box/config.json
如果没有报错,说明配置正确。
3. 重启 Sing-box 服务
使用 systemd 重启服务以应用新的配置:
sudo systemctl restart sing-box
如果 Sing-box 是通过其他方式启动的(比如手动运行或者 Supervisor 管理),需要根据具体启动方式来重启。
4. 检查服务状态
确保服务正常运行:
sudo systemctl status sing-box
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 程序员小航
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果