子痕的生活志 子痕的生活志
  • 首页
  • 分类
    • 随笔
    • 读书
    • 游玩
    • 摄影
    • 网络
    • 数码
  • 关于
  • 归档
  • 书单
  • 友链
  • 留言
首页 › 网络 › CentOS 6.x安装V2Ray

CentOS 6.x安装V2Ray

子痕
3月 9, 2019网络

20190310001_V2Ray-logo.png
V2Ray官方一键安装脚本代码

bash <(curl -L -s https://install.direct/go.sh)

上述脚本支持Debian7,Debian8和CentOS7系列,如果安装在CentOS 6.x上会报错。

报错内容

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,并添加执行权限。

#!/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

quot;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


quot;Stopping $NAME: "
killproc -p ${PIDFILE} ${NAME}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
}

reload() {
echo -n


quot;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

增加权限并加入开机启动

$ sudo chmod +x /etc/init.d/v2ray
$ sudo chkconfig v2ray on
$ sudo service v2ray start

安装官方脚本

运行官方一键安装脚本

bash <(curl -L -s https://install.direct/go.sh)

配置服务器

.json配置生成器https://intmainreturn0.com/v2ray-config-gen/
服务器.json地址:/etc/v2ray/config.json

CentOS v2Ray 扶墙 科学上网
赞赏
本文系作者 @子痕 原创发布在 子痕的生活志。未经许可,禁止转载。
去除Kindle电子书的DRM版权保护
上一篇
设置CentOS 6时区、日期、时间同步方法
下一篇
再想想
所有评论(5)
  • lwz

    按上面的做了,执行安装脚本后报pip3 no install

    4年前 回复
    • 子痕

      @lwz: 你是什么环境安装的呢?具体说下安装环境和操作步骤。

      4年前 回复
  • titan

    bash: ./v2ray: /bin/sh^M: bad interpreter: No such file or directory
    创建的这个脚本运行不了啊, sh后面怎么会有^M?

    3年前 回复
    • 子痕

      @titan: 我复制了没有,建议你先复制到记事本里,然后在复制粘贴。

      3年前 回复
  • 九凌网络

    有需要的时候再看看

    4月前 回复
近期文章
  • 梦回彩云之南
  • Twitter账号被冻结
  • 2023年元旦我们是这样跨的
  • 法院判了
  • 感染新冠病毒过程
  • 公司领头“羊”
  • 小米充电宝口袋版10000mAh
  • 重拾瑜伽
  • 喜剧小品《互联网体检》
  • 江苏园博园
Twitter账号被冻结
1月 14, 2023
29
谷歌翻译新网址
9月 30, 2022
24
Google镜像网站
7月 6, 2022
30
升级并续费服务器
9月 19, 2021
25
5
  • 0
  • 5
关于本站

子痕的生活记录、摄影、数码、折腾,玩物。。。

导航
首页 关于 留言
整站导航
首页 关于 留言
Copyright © 2019-2023 子痕的生活志. Designed by nicetheme.
  • 首页
  • 分类
    • 随笔
    • 读书
    • 游玩
    • 摄影
    • 网络
    • 数码
  • 关于
  • 归档
  • 书单
  • 友链
  • 留言
# CentOS # # 小神兽 # # Typecho # # Windows 10 # # Mate 30 Pro #
子痕