转自逗比大佬

系统要求

CentOS 7 / Debian 7+ / Ubuntu 14.04 +
ServerStatus 客户端需要 Python 2.7版本以上才可以正常运行,如果不是那么请升级(查看版本: python -V )。

注意:CentOS6 系统默认的Python版本是2.6,版本太低,使用客户端会出问题,请升级Python或者更换系统。

脚本版本

Ver: 1.0.13

安装步骤

执行下面的代码下载并运行脚本。

wget -N --no-check-certificate https://softs.wtf/Bash/status.sh && chmod +x status.sh
 
# 如果上面这个脚本无法下载,尝试使用备用下载:

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/status.sh && chmod +x status.sh

下载脚本后,根据需要安装客户端或者服务端:
主机安装服务端,其他VPS安装客户端

# 显示客户端管理菜单
bash status.sh c
 
# 显示服务端管理菜单
bash status.sh s

运行脚本后会出现脚本操作菜单,选择并输入 1 就会开始安装。

一开始会提示你输入网站服务器的域名和端口,如果没有域名可以直接回车代表使用 本机IP:8888如:123.123.123.123:8888

使用说明

进入下载脚本的目录并运行脚本:

# 客户端管理菜单
./status.sh c
# 服务端管理菜单
./status.sh s

然后选择你要执行的选项即可。

ServerStatus 一键安装管理脚本 [vx.x.x]
-- Toyo | doub.io/shell-jc3 --
 
 0. 升级脚本
————————————
 1. 安装 服务端
 2. 更新 服务端
 3. 卸载 服务端
————————————
 4. 启动 服务端
 5. 停止 服务端
 6. 重启 服务端
————————————
 7. 设置 服务端配置
 8. 查看 服务端信息
 9. 查看 服务端日志
————————————
10. 切换为 客户端菜单
 
当前状态: 服务端 已安装 并 已启动
 
请输入数字 [0-10]:

客户端:

启动:/etc/init.d/status-client start

停止:/etc/init.d/status-client stop

重启:/etc/init.d/status-client restart

查看状态:/etc/init.d/status-client status

服务端:

启动:/etc/init.d/status-server start

停止:/etc/init.d/status-server stop

重启:/etc/init.d/status-server restart

查看状态:/etc/init.d/status-server status

Caddy(HTTP服务):

启动:/etc/init.d/caddy start

停止:/etc/init.d/caddy stop

重启:/etc/init.d/caddy restart

查看状态:/etc/init.d/caddy status

Caddy配置文件:/usr/local/caddy/Caddyfile

安装目录:/usr/local/ServerStatus

网页文件:/usr/local/ServerStatus/web

配置文件:/usr/local/ServerStatus/server/config.json

客户端查看日志:tail -f tmp/serverstatus_client.log

服务端查看日志:tail -f /tmp/serverstatus_server.log

修改网页标题或公告

如果要修改网页标题或者网页顶部公告内容,打开 /usr/local/ServerStatus/web/index.html 文件修改即可,很显眼。

CentOS7系统 负载显示异常的问题

CentOS7系统 默认可能没有安装 netstat 依赖,所以会造成IP检测(负载)出错,手动安装即可: yum install net-tools -y

服务端网页显示异常,频繁开启/关闭

这种问题说明系统中的 Python版本低于 2.7(查看版本: python -V ),一般常见这种问题的都是 CentOS6 ,因为这个系统默认都是 Python2.6 版本,版本太低,使用客户端会出问题,请升级Python或者更换系统。

提示wget: unknown host “softs.wtf” 之类的错误

这是无法解析我的域名,多半是DNS的问题,请更换DNS为谷歌DNS(以下两行一起复制 一起执行)。

echo -e "nameserver 8.8.8.8
nameserver 8.8.4.4" > /etc/resolv.conf

提示 wget: command not found 的错误

这是你的系统精简的太干净了,wget都没有安装,所以需要安装wget。

# CentOS系统:
yum install -y wget
 
# Debian/Ubuntu系统:
apt-get install -y wget

Caddy启动失败,打开 http://ip 显示的是 It works !

一些系统会自带 apache2 ,而 apache2 会占用80端口,导致Caddy无法绑定端口,所以只要关掉就好了。

netstat -lntp
# 我们可以通过这个命令查看是不是被其他软件占用了 80 端口。
不过 apache2 会默认开机自启动,如果不需要可以关闭自启动或者卸载 apache2 。

停止 Apache2

service apache2 stop
# 尝试使用上面这个关闭,如果没效果或者提示什么错误无法关闭,那就用下面这个强行关闭进程。
kill -9 $(ps -ef|grep "apache2"|grep -v "grep"|awk '{print $2}')

取消开机自启动

# CentOS 系统 #
chkconfig --del httpd
# Debian/Ubuntu 系统 #
update-rc.d -f apache2 remove

卸载 Apache2(卸载包括了取消开机启动,无需重复)

# CentOS 系统 #
yum remove httpd
# Debian/Ubuntu 系统 #
apt-get remove --purge apache2

**关闭 Apache2后,就可以尝试启动 Caddy ,并试试能不能打开网页。

service caddy start

升级脚本

升级脚本只需要运行脚本,然后选择并输入0 回车即可,会自动检测最新版本并下载,当然重新下载脚本文件也可以,会自动覆盖原文件。