前言

从旧机器上进行迁移

复制数据

将执行文件打包拷贝过来,切到目录中执行sudo ./mihomo -d ./

此时可以访问http://[ip地址]:端口/ui 进行测试。

添加到systemd服务

修改/etc/systemd/system/mihomo.service

[Unit]
Description=mihomo Daemon, Another Clash Kernel.
After=network.target NetworkManager.service systemd-networkd.service iwd.service
 
[Service]
Type=simple
LimitNPROC=500
LimitNOFILE=1000000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
Restart=always
ExecStartPre=/usr/bin/sleep 1s
ExecStart=/opt/Clash/mihomo -d /opt/Clash/
ExecReload=/bin/kill -HUP $MAINPID
 
[Install]
WantedBy=multi-user.target

注意:请保证上面的 ExecStart 配置中 /opt/Clash/mihomo 和 /opt/Clash/ 路径正确,为你自己的mihomo程序路径和工作路径

重新加载systemd

systemctl daemon-reload

启动mihomo

systemctl start mihomo

参考文章

Clash WebUI 部署(Debian Linux 无桌面环境) Clash 图形化界面