Debian 系是 Linux 桌面用户最多的一支。这篇按实际操作顺序走一遍,包括很多教程会跳过的「装完之后系统怎么用上它」。
一、安装
用 apt 安装本地 deb 包
cd ~/Downloads
# 注意前面的 ./ 不能省,否则 apt 会去仓库里找同名包
sudo apt install ./v2rayN-linux-64.deb
# 如果提示缺依赖,先更新索引再重试
sudo apt update
sudo apt install -f二、启动
安装后应该能在应用菜单里找到图标。也可以从终端启动,好处是能直接看到报错:
从终端启动以观察输出
v2rayN
# 如果提示命令不存在,找一下实际路径
which v2rayN || dpkg -L v2rayn | grep bin三、让系统真正用上代理
这是 Linux 上最容易卡住的一步。和 Windows 不同,Linux 没有统一的「系统代理」概念,不同层级要分别配置。
桌面环境:GNOME 下在「设置 → 网络 → 网络代理」里选「手动」,HTTP 和 HTTPS 都填 127.0.0.1,端口填 10809。KDE 在「系统设置 → 网络 → 设置 → 代理」。
环境变量:加到 ~/.bashrc 或 ~/.zshrc
export http_proxy="http://127.0.0.1:10809"
export https_proxy="http://127.0.0.1:10809"
export all_proxy="socks5://127.0.0.1:10808"
export no_proxy="localhost,127.0.0.1,::1,*.local"
# 大写形式有些程序也读
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$https_proxyAPT 单独配置
sudo tee /etc/apt/apt.conf.d/95proxy > /dev/null <<'EOF'
Acquire::http::Proxy "http://127.0.0.1:10809";
Acquire::https::Proxy "http://127.0.0.1:10809";
EOF
# 不用时删掉这个文件即可
# sudo rm /etc/apt/apt.conf.d/95proxy四、开机自启
用桌面自启目录(推荐给图形环境)
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/v2rayn.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=v2rayN
Exec=v2rayN
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=15
EOFX-GNOME-Autostart-Delay=15 让它延迟 15 秒启动,等网络就绪,避免开机瞬间因为没有网络而全部测速失败。
五、没有图形界面的服务器怎么办
v2rayN 是图形客户端,在纯命令行的 VPS 上跑不起来。如果你要在无头服务器上用代理,正确的做法是直接运行内核:
思路:只用内核 + 一份配置文件 + systemd
# 1. 在有图形界面的机器上用 v2rayN 配好,导出生成的 config.json
# 2. 把内核二进制和 config.json 传到服务器
# 3. 写一个 systemd service 让它常驻
sudo tee /etc/systemd/system/xray.service > /dev/null <<'EOF'
[Unit]
Description=Xray Service
After=network-online.target
[Service]
ExecStart=/usr/local/bin/xray run -c /usr/local/etc/xray/config.json
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now xray
sudo systemctl status xray这样服务器上就有了一个常驻的本地代理端口,其他程序照常通过环境变量使用它。