[root]# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 22189 100 22189 0 0 42528 0 --:--:-- --:--:-- --:--:-- 42589 info: Installing V2Ray v5.2.1 for x86_64 Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v5.2.1/v2ray-linux-64.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 11.0M 100 11.0M 0 0 10.9M 0 0:00:01 0:00:01 --:--:-- 10.9M Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v5.2.1/v2ray-linux-64.zip.dgst info: Extract the V2Ray package to /tmp/tmp.WBXwFCQmXY and prepare it for installation. 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. ~~~~~~~~~~~~~~~~ [Unit] Description=V2Ray Service Documentation=https://www.v2fly.org/ After=network.target nss-lookup.target
[Install] WantedBy=multi-user.target # 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 ~~~~~~~~~~~~~~~~ warning: The systemd version on the current operating system is too low. warning: Please consider to upgrade the systemd or the operating system.
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.WBXwFCQmXY info: V2Ray v5.2.1 is installed. You may need to execute a command to remove dependent software: yum remove curl unzip Please execute the command: systemctl enable v2ray; systemctl start v2ray
试运行
安装完之后,使用以下命令启动 V2Ray:
1
[root]# systemctl start v2ray
在首次安装完成之后,V2Ray 不会自动启动,需要手动运行上述启动命令。
设置开机自启动 V2Ray:
1 2
[root]# systemctl enable v2ray Created symlink from /etc/systemd/system/multi-user.target.wants/v2ray.service to /etc/systemd/system/v2ray.service.
接下来看看 V2ray 是不是真的运行起来了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root]# systemctl status v2ray ● v2ray.service - V2Ray Service Loaded: loaded (/etc/systemd/system/v2ray.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/v2ray.service.d └─10-donot_touch_single_conf.conf Active: active (running) since Mon 2023-02-06 14:25:37 CST; 51s ago Docs: https://www.v2fly.org/ Main PID: 2354 (v2ray) CGroup: /system.slice/v2ray.service └─2354 /usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Feb 06 14:25:37 hachaos systemd[1]: Started V2Ray Service. Feb 06 14:25:37 hachaos v2ray[2354]: V2Ray 5.2.1 (V2Fly, a community-driven edition of V2Ray.) C...d64) Feb 06 14:25:37 hachaos v2ray[2354]: A unified platform for anti-censorship. Feb 06 14:25:37 hachaos v2ray[2354]: 2023/02/06 14:25:37 [Warning] V2Ray 5.2.1 started Hint: Some lines were ellipsized, use -l to show in full.
# 测试配置文件 [root]# /usr/local/bin/v2ray test -config /usr/local/etc/v2ray/config.json V2Ray 5.2.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.19.4 linux/amd64) A unified platform for anti-censorship. Configuration OK.
输出这样就表示配置文件没有问题。
接下来启动V2Ray
service v2ray start
开放端口
根据配置文件自己设置的端口,在服务器内或服务器管理网站开放相应端口。
V2Ray常用命令:
1 2 3 4 5 6 7 8 9 10 11 12
#启动 V2Ray service v2ray start #暂停 V2Ray service v2ray stop #查看 V2Ray 状态 service v2ray status #重启 V2Ray service v2ray restart #重装 V2Ray service v2ray reload #强制重装 V2Ray service v2ray force-reload