安装依赖软件
首先安装脚本的依赖软件,根据你的 Linux 发行版选择以下命令。
注意:下文中需要你输入的命令均以 $ 开头,其他内容均来自系统执行命令的反馈,你可以通过比较自己屏幕上和文档中内容的异同来判断安装是否正确。
Debian/Ubuntu:
$ apt update
$ apt install curl
CentOS/RedHat :
$ yum makecache
$ yum install curl
Fedora:
$ dnf makecache
$ dnf install curl
openSUSE/SUSE:
$ zypper refresh
$ zypper install curl
#下载安装脚本
下载主程序安装脚本:
$ curl -O 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
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 21613 100 21613 0 0 8732 0 0:00:02 0:00:02 --:--:-- 8736
#执行安装
安装 V2ray 主程序:
$ bash install-release.sh
Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.27.0/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
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 631 100 631 0 0 331 0 0:00:01 0:00:01 --:--:-- 331
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
100 12.2M 100 12.2M 0 0 841k 0 0:00:14 0:00:14 --:--:-- 1899k
Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.27.0/v2ray-linux-64.zip.dgst
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 636 100 636 0 0 294 0 0:00:02 0:00:02 --:--:-- 295
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
100 590 100 590 0 0 133 0 0:00:04 0:00:04 --:--:-- 282
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 172 kB of archives.
After this operation, 580 kB of additional disk space will be used.
Get:1 http://mirrors.163.com/debian buster/main amd64 unzip amd64 6.0-23+deb10u1 [172 kB]
Fetched 172 kB in 1s (173 kB/s)
Selecting previously unselected package unzip.
(Reading database ... 31383 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-23+deb10u1_amd64.deb ...
Unpacking unzip (6.0-23+deb10u1) ...
Setting up unzip (6.0-23+deb10u1) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for man-db (2.8.5-2) ...
info: unzip is installed.
info: Extract the V2Ray package to /tmp/tmp.vk9AF2EqKA/ and prepare it for installation.
installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/00_log.json
installed: /usr/local/etc/v2ray/01_api.json
installed: /usr/local/etc/v2ray/02_dns.json
installed: /usr/local/etc/v2ray/03_routing.json
installed: /usr/local/etc/v2ray/04_policy.json
installed: /usr/local/etc/v2ray/05_inbounds.json
installed: /usr/local/etc/v2ray/06_outbounds.json
installed: /usr/local/etc/v2ray/07_transport.json
installed: /usr/local/etc/v2ray/08_stats.json
installed: /usr/local/etc/v2ray/09_reverse.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.vk9AF2EqKA/
info: V2Ray v4.27.0 is installed.
You may need to execute a command to remove dependent software: apt remove curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray
看到类似于这样的提示就算安装成功了。如果安装不成功脚本会有提示语句,这个时候你应当按照提示除错,除错后再重新执行一遍脚本安装 V2Ray。对于错误提示如果看不懂,使用翻译软件翻译一下就好。
#运行
安装完之后,使用以下命令启动 V2Ray:
$ systemctl start v2ray
在首次安装完成之后,V2Ray 不会自动启动,需要手动运行上述启动命令。
设置开机自启动 V2Ray:
$ systemctl enable v2ray
接下来看看 V2ray 是不是真的运行起来了:
$ systemctl status v2ray
● v2ray.service - V2Ray Service
Loaded: loaded (/etc/systemd/system/v2ray.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2020-08-16 23:17:13 CST; 41min ago
Main PID: 1984 (v2ray)
Tasks: 6 (limit: 2359)
Memory: 6.9M
CGroup: /system.slice/v2ray.service
└─1984 /usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/01_api.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/02_dns.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/03_routing.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/04_policy.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/05_inbounds.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/06_outbounds.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/07_transport.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/08_stats.json
Aug 16 23:17:13 debian v2ray[1984]: v2ctl> Read config: /usr/local/etc/v2ray/09_reverse.json
Aug 16 23:17:13 debian v2ray[1984]: 2020/08/16 23:17:13 [Warning] v2ray.com/core: V2Ray 4.27.0 start
lines 1-19/19 (END)
看到类似于这样的提示就算启动成功了。
但是由于此时你还没有为 V2ray 配置,所以咱们还是把它关掉吧:
$ systemctl stop v2ray
对于安装脚本,还有更多用法,在此不多说了,可以执行 bash install-release.sh -h 看帮助。
关于 V2ray 配置,请参考 v2ray-examples (opens new window)内的示例。
#升级更新
在 VPS,重新执行一遍安装脚本就可以更新了,在更新过程中会自动重启 V2Ray,配置文件保持不变。
$ bash install-release.sh
暂无评论