Ubuntu Server 配置 Clash
本文最后更新于:2025年9月13日 下午
安装 clash
启动
1
2
3cd /clash
wget -O config.yaml https://your subscribe url
./clash -d ./设置系统代理
1
2
3
4
5sudo vim ~/.zshrc
// 加入并保存
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 no_proxy="localhost,127.0.0.1"
//更新
source ~/.zshrc启用和禁用命令
1
2
3
4
5
6#禁用全局代理
unset http_proxy
unset https_proxy
#启用全局代理
set http_proxy
set https_proxy
设置clash开机启动
创建服务文件:
1
sudo vim /etc/systemd/system/clash.service
填入以下内容(修改路径为你的 Clash 可执行文件和配置文件路径):
1
2
3
4
5
6
7
8
9
10
11
12
13[Unit]
Description=Clash Service
After=network.target
[Service]
Type=simple
ExecStart=/home/zzmes/workspace/tools/clash/clash -d /home/zzmes/workspace/tools/clash
Restart=on-failure
User=zzmes
WorkingDirectory=/home/zzmes/workspace/tools/clash
[Install]
WantedBy=multi-user.target保存后执行:
1
2
3
4sudo systemctl daemon-reload
sudo systemctl enable clash # 开机启动
sudo systemctl start clash # 立即启动
sudo systemctl status clash # 查看状态
Clash相关的管理命令
1 |
|