https://github.com/wnlen/clash-for-linux
x
1. 下载 Clash For Linux. # https://github.com/wnlen/clash-for-linux/archive/refs/heads/master.zip 2. 进入到项目目录,编辑 .env 文件,修改里面的 CLASH_URL 的值. 值改为自己的 Clash 订阅. # CLASH_SECRET 为自定义 Clash Secret,值为空时,脚本将自动生成随机字符串。
3. 启动程序. # 直接运行脚本文件 start.sh ; # 会有一些输出: # …省略 ( 都是 xxx [ok] ) # Clash Dashboard 访问地址:http://<ip>:9090/ui # Secret:xxxxxxxxxxxxx # 请执行以下命令加载环境变量: source /etc/profile.d/clash.sh # 请执行以下命令开启系统代理: proxy_on # 若要临时关闭系统代理,请执行: proxy_off
4. 按说明执行命令. # source /etc/profile.d/clash.sh # proxy_on
5. 检查服务端口. # netstat -tln | grep -E '9090|789.' # 结果应该是输出有 9090 7890 7891 端口
6. 检查环境变量. # env | grep -E 'http_proxy|https_proxy' http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890
7. 测试 # 找个国外站点内容, wget 一下. # wget https://archive.org/download/grand-theft-auto-san-andreas-pc/grand-theft-auto-san-andreas-pc_archive.torrent # 测速: speedtest.net 注意不是 .cn`
8. 下载成功表示科学上网成功.
9. 重启程序 # 如果需要对Clash配置进行修改,请修改 conf/config.yaml 文件。然后运行 restart.sh 脚本进行重启。 # 注意: 重启脚本 restart.sh 不会更新订阅信息。
10. 停止程序 # bash shutdown.sh # proxy_off # 然后检查程序端口、进程以及环境变量http_proxy|https_proxy,若都没则说明服务正常关闭。
xxxxxxxxxx1. 写一个 Unit 配置文件,用 systemctl 管理 [root@ubt-k8s-servername ~]# systemctl cat clash-for-linux.service # /lib/systemd/system/clash-for-linux.service [Unit] Description=Clash for Linux Service After=network.target [Service] Type=forking ExecStart=/bin/bash /root/clash-for-linux-master/start.sh && proxy_on ExecStop=/bin/bash /root/clash-for-linux-master/shutdown.sh && proxy_off ExecReload=/bin/bash /root/clash-for-linux-master/shutdown.sh && proxy_off && /bin/bash /root/clash-for-linux-master/start.sh && proxy_on Restart=on-failure [Install] WantedBy=multi-user.target 2. systemctl daemon-reload 生效.
3. systemctl enable --now clash-for-linux && proxy_on
4. 完事
5. 有的在新终端不管用,可以用 proxy_on 打开.
# 通过浏览器访问 start.sh 执行成功后输出的地址. # 登陆管理界面 # 在API Base URL一栏中输入 http://<ip>:9090 ,在Secret(optional)一栏中输入启动成功后输出的Secret。 # 点击Add并选择刚刚输入的管理界面地址,之后便可在浏览器上进行一些配置。
xxxxxxxxxx### 一些注意事项 ###
1. 以上操作只在当前终端生效; # 解决办法见: 配置后台运行. 2. Linux-Desktop 中,只有当前终端生效的问题. # 设置全局代理 # 右上角 '网络设置' # 01. 网络设置 - 网络代理 - 设置图标 # 02. 手动 # 03. HTTP代理 127.0.0.1 7890 # HTTPS代理 127.0.0.1 7890 # Socks主机 127.0.0.1 7891 3. Linux-Desktop 中,关闭开代理的终端,代理失效; # 解决办法见: 配置后台运行.
