使用zxcvos大神开发的Xray 管理脚本,搭建梯子,实现科学上网。
1丶获取脚本
wget --no-check-certificate -O ${HOME}/Xray-script.sh https://raw.githubusercontent.com/zxcvos/Xray-script/main/install.shBash2丶启动界面
root@VM98783:~# bash ${HOME}/Xray-script.sh
__ __ _ _ _______ _______ _____
\ \ / / | | | | |__ __| |__ __| | __ \
\ V / | |__| | | | | | | |__) |
> < | __ | | | | | | ___/
/ . \ | | | | | | | | | |
/_/ \_\ |_| |_| |_| |_| |_|
Copyright (C) zxcvos | https://github.com/zxcvos/Xray-script
------------------------------------------------------
Xray : 未安装
CONFIG : 未配置
WARP Proxy : 未启动
------------------------------------------------------
--------------- Xray-script ------------------
Version : v2025.9.2
Description : Xray 管理脚本
------------------ 装载管理 ------------------
1. 完整安装
2. 仅安装/更新
3. 卸载
------------------ 操作管理 ------------------
4. 启动
5. 停止
6. 重启
------------------ 配置管理 ------------------
7. 分享链接与二维码
8. 信息统计
9. 管理配置
------------------------------------------------------
0. 退出
[提示] 请选择操作: Bash2.1安装Xray
根据提示选择操作2. 仅安装/更新。
[提示] 请选择操作: 2
------------------ 装载管理 ------------------
1. 最新本
2. 稳定本(默认)
3. 自选版
------------------------------------------------------
1. 最新版包含了 pre-release 版本
2. 稳定版为最新发布的非 pre-release 版本
3. 自选版可能存在配置不兼容问题,请自行解决
------------------------------------------------------
[提示] 请选择操作: Bash这里我们选择稳定本,并Enter继续。
[提示] 请选择操作: 2
% 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 31120 100 31120 0 0 30569 0 0:00:01 0:00:01 --:--:-- 30569
info: Installing specified Xray version v25.9.11 for x86_64
Downloading Xray archive: https://github.com/XTLS/Xray-core/releases/download/v25.9.11/Xray-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 19.3M 100 19.3M 0 0 2855k 0 0:00:06 0:00:06 --:--:-- 3049k
ok.
Downloading verification file for Xray archive: https://github.com/XTLS/Xray-core/releases/download/v25.9.11/Xray-linux-64.zip.dgst
ok.
info: Extract the Xray package to /tmp/tmp.W9r2dP9yFx and prepare it for installation.
rm: cannot remove '/etc/systemd/system/xray.service.d/10-donot_touch_multi_conf.conf': No such file or directory
rm: cannot remove '/etc/systemd/system/xray@.service.d/10-donot_touch_multi_conf.conf': No such file or directory
info: Systemd service files have been installed successfully!
warning: The following are the actual parameters for the xray service startup.
warning: Please make sure the configuration file path is correctly set.
# /etc/systemd/system/xray.service
[Unit]
Description=Xray Service
Documentation=https://github.com/xtls
After=network.target nss-lookup.target
[Service]
User=root
#CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
#NoNewPrivileges=true
ExecStart=/usr/local/bin/xray run -config /usr/local/etc/xray/config.json
Restart=on-failure
RestartPreventExitStatus=23
LimitNPROC=10000
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/xray.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/xray run -config /usr/local/etc/xray/config.json
installed: /usr/local/bin/xray
installed: /usr/local/share/xray/geoip.dat
installed: /usr/local/share/xray/geosite.dat
installed: /usr/local/etc/xray/config.json
installed: /var/log/xray/
installed: /var/log/xray/access.log
installed: /var/log/xray/error.log
installed: /etc/systemd/system/xray.service
installed: /etc/systemd/system/xray@.service
removed: /tmp/tmp.W9r2dP9yFx
info: Xray v25.9.11 is installed.
You may need to execute a command to remove dependent software: apt purge curl unzip
Created symlink /etc/systemd/system/multi-user.target.wants/xray.service → /etc/systemd/system/xray.service.
info: Enable and start the Xray serviceBash到这里,我们可以看到 Xray v25.9.11 已经被安装好。
然后我们查看xray的运行状态。
root@VM98783:~# sudo systemctl status xray
● xray.service - Xray Service
Loaded: loaded (/etc/systemd/system/xray.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/xray.service.d
└─10-donot_touch_single_conf.conf
Active: active (running) since Tue 2025-10-07 05:47:37 UTC; 17s ago
Docs: https://github.com/xtls
Main PID: 311944 (xray)
Tasks: 6 (limit: 1042)
Memory: 3.7M
CGroup: /system.slice/xray.service
└─311944 /usr/local/bin/xray run -config /usr/local/etc/xray/config.json
Oct 07 05:47:37 VM98783 systemd[1]: Started Xray Service.
Oct 07 05:47:37 VM98783 xray[311944]: Xray 25.9.11 (Xray, Penetrates Everything.) 3edfb0e (go1.25.1 linux/amd64)
Oct 07 05:47:37 VM98783 xray[311944]: A unified platform for anti-censorship.
Oct 07 05:47:37 VM98783 xray[311944]: 2025/10/07 05:47:37.210136 [Info] infra/conf/serial: Reading config: &{Name:/usr/local/etc/xray/config.json Format:json}
Oct 07 05:47:37 VM98783 xray[311944]: 2025/10/07 05:47:37.211820 [Warning] core: Xray 25.9.11 startedBash这里,我们可以看到Xray已经正常运行了。
2.2配置Xray
我们再次打开脚本界面,发现此时已经能正常显示出Xray的版本号。
root@VM98783:~# bash ${HOME}/Xray-script.sh
__ __ _ _ _______ _______ _____
\ \ / / | | | | |__ __| |__ __| | __ \
\ V / | |__| | | | | | | |__) |
> < | __ | | | | | | ___/
/ . \ | | | | | | | | | |
/_/ \_\ |_| |_| |_| |_| |_|
Copyright (C) zxcvos | https://github.com/zxcvos/Xray-script
------------------------------------------------------
Xray : v25.9.11
CONFIG : 未配置
WARP Proxy : 未启动
------------------------------------------------------
--------------- Xray-script ------------------
Version : v2025.9.2
Description : Xray 管理脚本
------------------ 装载管理 ------------------
1. 完整安装
2. 仅安装/更新
3. 卸载
------------------ 操作管理 ------------------
4. 启动
5. 停止
6. 重启
------------------ 配置管理 ------------------
7. 分享链接与二维码
8. 信息统计
9. 管理配置
------------------------------------------------------
0. 退出
[提示] 请选择操作: Bash这里选择操作9. 管理配置,对Xray进行配置。
[提示] 请选择操作: 9
------------------ 管理配置 ------------------
1. 更新配置
2. 分流管理
3. SNI 配置管理
4. 开/关 geodata 自动更新
5. 设置语言
------------------------------------------------------
1. 更新配置功能为整个配置的更新
2. 管理屏蔽或 WARP 分流
3. 包含 Nginx 更新,修改域名,修改 Web 配置等
4. geodata 由 https://github.com/Loyalsoldier/v2ray-rules-dat 提供
------------------------------------------------------
[提示] 请选择操作: Bash这里我们选择操作1. 更新配置。
[提示] 请选择操作: 1
------------------ 可选配置 ------------------
1. VLESS+mKCP+seed
2. VLESS+Vision+REALITY(默认)
3. VLESS+XHTTP+REALITY
4. Trojan+XHTTP+REALITY
5. 双协议复合配置
6. SNI分流复合配置
------------------------------------------------------
1. mKCP 牺牲带宽来降低延迟。传输同样的内容,mKCP 一般比 TCP 消耗更多的流量
2. XTLS(Vision) 解决 TLS in TLS 问题
3. XHTTP 全场景通吃的时代正式到来(详情: https://github.com/XTLS/Xray-core/discussions/4113 )
3.1. XHTTP 默认有多路复用,延迟比 Vision 低但多线程测速不如它
3.2. 此外 v2rayN&G 客户端有全局 mux.cool 设置,用 XHTTP 前记得关闭,不然连不上新版 Xray 服务端
4. VLESS 替换为 Trojan
5. 利用 VLESS+Vision+REALITY 回落 VLESS+XHTTP 共用 443 端口
6. 通过 Nginx 的 SNI 分流共用 443 端口,实现 REALITY 直连与过 CDN 共存
------------------------------------------------------
[提示] 请选择操作: Bash这里我们选择操作2. VLESS+Vision+REALITY(默认)。
[提示] 请选择操作: 2
[信息] 正在检查 Xray 配置原文件是否存在:/usr/local/xray-script/config/xray/Vision.json
[通过] Xray 配置原文件存在:/usr/local/xray-script/config/xray/Vision.json
[配置] 是否重置路由规则 [y/N] y
[配置] 是否开启 bittorrent 屏蔽 [Y/n] y
[配置] 是否开启国内 ip 屏蔽 [Y/n] y
[配置] 是否开启广告屏蔽 [Y/n] y
[配置] 请输入 port (端口范围是 1-65535 ,默认: 443, mKCP随机生成): m_port
[信息] 正在检查端口合法性:m_port
[通过] 端口号合法:m_port
[配置] 请输入 UUID (支持自定义字符串,默认自动生成):
[信息] 正在检查 UUID 类型:
[通过] 输入值为空,将自动生成一份 UUID
[配置] 请输入目标域名 target (默认随机选择): m_domain
[信息] 正在检查域名安全性:m_domain
[测试] 正在解析域名:m_domain
[测试] 正在测试 TCP 连接:: m_domain:443
[测试] 正在获取 TLS 信息:: m_domain
[通过] 支持 TLS 1.3
[通过] 使用 X25519 密钥交换
[通过] 域名 m_domain 安全性检查通过
[提示] 支持输入 0 到 8 自动生成对应倍数长度的 shortId
[配置] 请输入 shortId (多个值请用英文逗号分隔,默认自动生成): m_shortId
[信息] 正在检查 shortId 合法性:m_shortId
[通过] shortId 合法:m_shortId
[配置] 正在更新脚本配置
[配置] 正在更新脚本配置
[Private Key] m_private_key
[Public Key] m_public_key
[Hash32] m_hash32
[配置] 正在更新 Xray 配置Bash到此,我们就完成了Xray的配置,我们将最后输出的分享链接复制粘贴到v2rayN就可以使用了。
注:我们配置Xray使用的是自己的网站,配置完Xray会发现我们的网站访问不了了,经过排查是
Nginx服务掉了,查其状态变成了Active: inactive (dead),我们通过sudo systemctl restart nginx将Nginx服务重启,网站就能恢复访问了。