本文主要内容来自新V2ray白话文指南↗和新手上路↗,使用的脚本来自fhs-install-v2ray↗。
V2ray不推荐使用APT安装,一方面是包老旧,Debian/Ubuntu官方源为4.34版本,而最新版本为5.16.1,另一方面打包较差↗。
下载并执行脚本
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
sudo bash install-release.sh
脚本直接从GitHub下载,网络不通是肯定的,所以更有效的操作是提前下载安装文件本地安装:
sudo bash install-release.sh -l v2ray-linux-64.zip
warn: Install V2Ray from a local file, but still need to make sure the network is available.
warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...
这两个只是免责条款,按任意键继续就好,下列是一些有用的输出:
info: Systemd service files have been installed successfully!
warning: The following are the actual parameters for the v2ray service startup.
warning: Please make sure the configuration file path is correctly set.
# /etc/systemd/system/v2ray.service
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target
[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf
# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
installed: /usr/local/bin/v2ray
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
removed: /tmp/tmp.FYoxoTf4yg
info: V2Ray v5.16.1 is installed.
You may need to execute a command to remove dependent software: apt purge curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray
注意,脚本会自动安装curl用于下载,unzip用于zip压缩包解压,其中unzip不是预置软件,可能需要手动卸载unzip并恢复curl的自动安装标记。
脚本安装结束后自动移除临时文件,无需另外清理。
另外注意此安装脚本提供的配置位置在/usr/local/etc/v2ray/config.json
,并且使用systemd
管理,服务名为v2ray.service
。
V2ray作为一个开源项目,管理混乱和信息过时在所难免,比如上面那篇白话文指南里面充满了2018年的时间戳,软件版本还停留在4.x。而在官方网站(v2fly)↗里居然第一眼看不到详尽的用户手册,转了两个弯才在另一个官方网站(v2ray)↗找到,而这个站一进去就是一个超大用户手册拍脸上。
软件的更新进度倒还跟得上,但相关的手册编写简直是一坨,包管理和打包也是一坨。
宣言也扭扭捏捏,充满寡妇下海的感觉,非常神秘。
此外,脚本作者没有写清楚脚本的附加选项,在GitHub自述页面↗仅提供了一些基本操作,下面列出脚本的附加参数及作用:
usage: install-release.sh [--remove | --version number | -c | -f | -h | -l | -p] [-p address] [--version number | -c | -f]
--remove Remove V2Ray
--version Install the specified version of V2Ray, e.g., --version v4.18.0
-c, --check Check if V2Ray can be updated
-f, --force Force installation of the latest version of V2Ray
-h, --help Show help
-l, --local Install V2Ray from a local file
-p, --proxy Download through a proxy server, e.g., -p http://127.0.0.1:8118 or -p socks5://127.0.0.1:1080