CentOS 6.x安装V2Ray
V2Ray官方一键安装脚本代码
1
2
|
bash <(curl -L -s https://install.direct/go.sh)
|
上述脚本支持Debian7,Debian8和CentOS7系列,如果安装在CentOS 6.x上会报错。
报错内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
Installing V2Ray v4.18.0 on i686
Downloading V2Ray: https://github.com/v2ray/v2ray-core/releases/download/v4.18.0/v2ray-linux-32.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10.0M 100 10.0M 0 0 5854k 0 0:00:01 0:00:01 --:--:-- 8879k
Updating software repo
Installing unzip
Extracting V2Ray package to /tmp/v2ray.
Archive: /tmp/v2ray/v2ray.zip
inflating: /tmp/v2ray/config.json
creating: /tmp/v2ray/doc/
inflating: /tmp/v2ray/doc/readme.md
inflating: /tmp/v2ray/geoip.dat
inflating: /tmp/v2ray/geosite.dat
creating: /tmp/v2ray/systemd/
inflating: /tmp/v2ray/systemd/v2ray.service
creating: /tmp/v2ray/systemv/
inflating: /tmp/v2ray/systemv/v2ray
inflating: /tmp/v2ray/v2ctl
extracting: /tmp/v2ray/v2ctl.sig
inflating: /tmp/v2ray/v2ray
extracting: /tmp/v2ray/v2ray.sig
inflating: /tmp/v2ray/vpoint_socks_vmess.json
inflating: /tmp/v2ray/vpoint_vmess_freedom.json
PORT:241**
UUID:f51b5ec3-***********
Installing daemon
Error: Nothing to do
Failed to install daemon. Please install it manually.
|
解决方法
将下述代码保存为/etc/init.d/v2ray,并添加执行权限。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#!/bin/sh
#
# v2ray Startup script for v2ray
#
# chkconfig: - 24 76
# processname: v2ray
# pidfile: /var/run/v2ray.pid
# description: V2Ray proxy services
#
### BEGIN INIT INFO
# Provides: v2ray
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: V2Ray proxy services
# Description: V2Ray proxy services
### END INIT INFO
DESC=v2ray
NAME=v2ray
DAEMON=/usr/bin/v2ray/v2ray
PIDFILE=/var/run/$NAME.pid
LOCKFILE=/var/lock/subsys/$NAME
SCRIPTNAME=/etc/init.d/$NAME
RETVAL=0
DAEMON_OPTS="-config /etc/v2ray/config.json"
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Source function library.
. /etc/rc.d/init.d/functions
start() {
local pids=$(pgrep -f $DAEMON)
if [ -n "$pids" ]; then
echo "$NAME (pid $pids) is already running"
RETVAL=0
return 0
fi
echo -n $"Starting $NAME: "
mkdir -p /var/log/v2ray
$DAEMON $DAEMON_OPTS 1>/dev/null 2>&1 &
echo $! > $PIDFILE
sleep 2
pgrep -f $DAEMON >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success; echo
touch $LOCKFILE
else
failure; echo
fi
return $RETVAL
}
stop() {
local pids=$(pgrep -f $DAEMON)
if [ -z "$pids" ]; then
echo "$NAME is not running"
RETVAL=0
return 0
fi
echo -n $"Stopping $NAME: "
killproc -p ${PIDFILE} ${NAME}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
}
reload() {
echo -n $"Reloading $NAME: "
killproc -p ${PIDFILE} ${NAME} -HUP
RETVAL=$?
echo
}
rh_status() {
status -p ${PIDFILE} ${DAEMON}
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
stop
start
;;
reload)
reload
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|reload|restart}" >&2
RETVAL=2
;;
esac
exit $RETVAL
|
增加权限并加入开机启动
1
2
3
4
|
$ sudo chmod +x /etc/init.d/v2ray
$ sudo chkconfig v2ray on
$ sudo service v2ray start
|
安装官方脚本
运行官方一键安装脚本
1
2
|
bash <(curl -L -s https://install.direct/go.sh)
|
配置服务器
.json配置生成器https://intmainreturn0.com/v2ray-config-gen/
服务器.json地址:/etc/v2ray/config.json
按上面的做了,执行安装脚本后报pip3 no install
@lwz: 你是什么环境安装的呢?具体说下安装环境和操作步骤。
bash: ./v2ray: /bin/sh^M: bad interpreter: No such file or directory
创建的这个脚本运行不了啊, sh后面怎么会有^M?
@titan: 我复制了没有,建议你先复制到记事本里,然后在复制粘贴。