[运维] wvp 28181安装部署全流程(centos7)
部署wvp
系统环境
系统版本
:centos 7.9
安装java、git
yum install java-11-openjdk git tar vim
安装ffmepg
#安装EPEL Release,因为安装需要使用其他的repo源,所以需要EPEL支持:
sudo yum install -y epel-release
#如果出现缺少Code提示,可以:
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
#安装完成之后,可以查看是否安装成功
sudo yum repolist
# 安装Nux-Dextop源
# 导入一个Code
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
#安装nux-dextop 源
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
#查看repo源是否安装成功
sudo yum repolist
# yum安装ffmpeg:
sudo yum install -y ffmpeg
# 安装完成后检查ffmpeg 版本:
ffmpeg -version
编译zlm
安装编译工具
sudo yum install cmake3 gcc gcc-c++
编译zlm
git clone https://gitee.com/xia-chu/ZLMediaKit.git
cd ZLMediaKit
git submodule update --init --recursive
mkdir -p build release/linux/Release/
cd build
cmake3 -DCMAKE_BUILD_TYPE=Release -DENABLE_WEBRTC=false -DENABLE_TESTS=false ..
cmake3 --build . --target MediaServer
搭建wvp开发环境
安装maven
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
mkdir app
tar xf apache-maven-3.8.6-bin.tar.gz
mv apache-maven-3.8.6 app/maven
echo "export PATH=~/app/maven/bin:\$PATH" >> ~/.bashrc
## 环境变量生效
source ~/.bashrc
安装nodejs
wget https://nodejs.org/dist/v16.19.0/node-v16.19.0-linux-x64.tar.gz
tar xf node-v16.19.0-linux-x64.tar.gz
mv node-v16.19.0-linux-x64 app/node
echo "export PATH=~/app/node/bin:\$PATH" >> ~/.bashrc
## 环境变量生效
source ~/.bashrc
编译wvp
签出代码
git clone https://gitee.com/pan648540858/wvp-GB28181-pro.git
编译前端
cd wvp-GB28181-pro/web_src
# 下载依赖
npm install --registry=https://registry.npmmirror.com
# 编译
npm run build
编译后端
cd ..
mvn clean package -DskipTests
部署docker
curl -sfL https://get.rainbond.com/install_docker | bash
部署docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/v2.14.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
## 或者
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/v2.14.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
部署数据库和redis
- 创建安装目录
## 创建储存目录
mkdir -p /opt/video/mysqldata
mkdir -p /opt/video/redisdata
- 创建yml文件
cd /opt/video
vim video.yml
将以下内容复制到vim
编辑器中
version: "3.8"
services:
redis:
image: redis:6.2-alpine
restart: always
environment:
TZ: Asia/Shanghai
ports:
- 6379:6379
volumes:
- /opt/video/redisdata/data:/data
- /opt/video/redisdata/log:/logs
command: redis-server --port 6379 --requirepass 12345678 --appendonly yes
mysql:
image: mysql:8
restart: always
command:
[
"--character-set-server=utf8mb4",
"--collation-server=utf8mb4_unicode_ci",
"--default-time-zone=+8:00",
]
ports:
- 3306:3306
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 12345678
SQL_MODE: "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
volumes:
- /opt/video/mysqldata/mysql:/var/lib/mysql:rw
- 启动数据库和redis
# 将镜像pull下来
docker pull redis:6.2-alpine
docker pull mysql:8
## 启动
docker-compose -f video.yml -p wvp up -d
部署zlm
- 创建安装目录
mkdir -p /opt/video/zlm
- 复制zlm启动文件到安装目录
# 进入zlm项目目录
cd ~/ZLMediaKit
cp -r release/linux/Release/* /opt/video/zlm/
- 创建开机启动脚本
vim /etc/systemd/system/zlm.service
将以下内容复制到vim
编辑器
[Unit]
Description=ZLMediaKit
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/opt/video/zlm/MediaServer -c /opt/video/zlm/config.ini
StandardOutput=null
[Install]
WantedBy=multi-user.target
- 启动zlm
# 设置开机启动
systemctl enable zlm
# 启动zlm
systemctl start zlm
- 其他
# 重启zlm
systemctl restart zlm
# 停止zlm
systemctl stop zlm
# 查看启动状态
systemctl status zlm
部署wvp
- 导入sql文件
## 进入wvp项目
cd ~/wvp-GB28181-pro/
## 复制mysql.sql、update.sql文件到mysql容器
docker cp sql/mysql.sql wvp-mysql-1:/tmp
docker cp sql/update.sql wvp-mysql-1:/tmp
## 进入mysql容器
docker exec -it wvp-mysql-1 bash
## 登录数据库
mysql -uroot -p12345678
## 创建wvp数据库
CREATE DATABASE `wvp` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
- 创建安装目录
mkdir -p /opt/video/wvp
- 复制jar文件和配置到安装目录
cd ~/wvp-GB28181-pro/
# 复制java包安装目录
cp target/wvp-pro-2.6.6-xxxxx.jar /opt/video/wvp/wvp-pro-2.6.6.jar
# 复制配置文件安装目录
cp src/main/resources/all-application.yml /opt/video/wvp/application.yml
- 创建开机启动文件
vim /etc/systemd/system/wvp.service
将以下内容复制到vim
编辑器
[Unit]
Description=wvp
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/usr/bin/java -jar /opt/video/wvp/wvp-pro-2.6.6.jar --spring.config.location=/opt/video/wvp/application.yml
StandardOutput=null
[Install]
WantedBy=multi-user.target
- 启动wvp
# 设置开机启动
systemctl enable wvp
# 启动wvp
systemctl start wvp
- 其他
# 重启wvp
systemctl restart wvp
# 停止wvp
systemctl stop wvp
# 查看启动状态
systemctl status wvp
登录
登录地址
http://xxx.xxx.xxx.xxx:18080
用户名/密码:admin/admin
需要远程协助可私信我