0


如何在Linux上配置sing-box

如何在Linux上配置sing-box

安装方法:

  • Debian / DEB:
bash<(curl-fsSL[https://sing-box.app/deb-install.sh](https://sing-box.app/deb-install.sh))
  • Redhat / RPM
bash<(curl-fsSL[https://sing-box.app/rpm-install.sh](https://sing-box.app/rpm-install.sh))
  • Archlinux / PKGArchlinux / PKG操作系统
bash<(curl-fsSL[https://sing-box.app/arch-install.sh](https://sing-box.app/arch-install.sh)

启动

# 启动服务
systemctl start sing-box.service
# 查看启动状态
systemctl status sing-box.service
# 设置开机启动
systemctl enable sing-box.service
# 运行 -c 指定一个配置文件
sing-box run -c /etc/sing-box/config.json

项目路径程序/usr/bin/sing-box配置/etc/sing-box/config.json工作目录/var/lib/sing-box服务文件/etc/systemd/system/sing-box.service热载systemctl reload sing-box重启systemctl restart sing-box状态systemctl status sing-box查看日志journalctl -u sing-box -o cat -e实时日志journalctl -u sing-box -o cat -f

卸载:

  • Debian/Ubuntu
# --purge会把配置也删除,保留配置请移除该参数sudo systemctl stop sing-box.service
sudo systemctl disable sing-box.service
sudo dpkg --purge sing-box
  • CentOS/Fedora
# --allmatches会把配置也删除,保留配置请移除该参数sudo systemctl stop sing-box.service
sudo systemctl disable sing-box.service
sudorpm-e--allmatches sing-box
  • Archlinux
# -n参数会把配置也删除,保留配置请移除该参数sudo systemctl stop sing-box.service
sudo systemctl disable sing-box.service
sudo pacman -Rn sing-box

通过docker安装:

配置目录映射到宿主机: /etc/sing-box 目录下

  1. 安装docker
sudocurl-fsSL https://get.docker.com |bash-sdocker
  1. 启动docker
sudo systemctl start docker
  1. 新建docker-compose.yaml配置文件
mkdir ~/sing-box
cat <<EOF> ~/sing-box/docker-compose.yaml
version:"3.8"services:sing-box:image: ghcr.io/sagernet/sing-box
    container_name: sing-box
    restart: always
    volumes:- /etc/sing-box:/etc/sing-box/
    command:-D /var/lib/sing-box -C /etc/sing-box/ run
EOF
  1. 运行
cd ~/sing-box
docker-compose up -d
  1. 卸载
docker-compose down
rm-rf /etc/sing-box
标签: linux 运维 服务器

本文转载自: https://blog.csdn.net/qq562920276/article/details/137365200
版权归原作者 扶苏如是 所有, 如有侵权,请联系我们删除。

“如何在Linux上配置sing-box”的评论:

还没有评论