常规方式
一、下载clash for linux
下载地址:https://github.com/Dreamacro/clash/releases
二、配置并运行clash
将下载好的文件上上传到对应的位置后,创建存储的文件夹,将文件剪切到指定位置,将本地windows机器clash的配置复制到对应我们/opt/clash/clash 下的config.yaml,内容填充完毕后,执行下面ip库的命令,在以后台方式启动clash
➜ gunzip ./文件gz➜ mkdir /opt/clash➜ mv ./解压后的文件 /opt/clash/clash➜ cd /opt/clash➜ chmod +x clash➜ wget -O config.yaml [订阅链接] #多出一个config.yaml文件➜ wget -O Country.mmdb "https://www.sub-speeder.com/client-download/Country.mmdb" #多出一个Country.mmdb文件➜ ./clash -d .
三、以服务形式运行clash
1.创建service文件touch /etc/systemd/system/clash.service2.编辑service文件vi /etc/systemd/system/clash.service```bash[Unit]Description=clash daemon[Service]Type=simpleUser=rootExecStart=/opt/clash/clash -d /opt/clash/Restart=on-failure[Install]WantedBy=multi-user.target
3.重新加载systemctl daemon systemctl daemon-reload 4.启动Clash systemctl start clash.service 5.设置Clash开机自启动 systemctl enable clash.service 6.查看服务日志 journalctl -f -u clash.service 7.放开zsh代理 export http_proxy=http://127.0.0.1:7890 export https_proxy=http://127.0.0.1:7890 export no_proxy=localhost,127.0.0.1,192.168.1.0/24,10.100.0.0/16,10.96.0.0/12,::1
重启Clash
systemctl restart clash.service
查看Clash运行状态
systemctl status clash.service
> 转载参考:[https://zhuanlan.zhihu.com/p/369344633](https://zhuanlan.zhihu.com/p/369344633)<a name="BYDQy"></a>## docker-compose方式当然以docker的形式去启动也是可行的,只需要挂在一个config.yaml即可。```bashversion: '3'services:clash:container_name: clashimage: dreamacro/clashvolumes:- ./config.yaml:/root/.config/clash/config.yaml# dashboard volume# - ./ui:/uiports:- "7890:7890"#- "7891:7891"- "9090:9090"# If you need external controller, you can export this port.# - "8080:8080"restart: always# When your system is Linux, you can use `network_mode: "host"` directly.# network_mode: "host"
