CentOS7下离线编译ZLMediaKit

发布时间 2024-01-02 11:17:59作者: 枫中落叶123

系统环境

CentOS版本号

CentOS Linux release 7.9.2009 (Core)

内核版本

Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

 

 镜像下载地址

https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/?spm=a2c6h.25603864.0.0.196df5adF9cHsb

 

 

 切换到root用户

如果不是root用户进行操作的话,可能会有权限限制问题

su root 

安装包准备

在可以联网的电脑上(windowscentos均可),下载ZLMediaKit 

git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit

cd ZLMediaKit

#千万不要忘记执行这句命令

git submodule update --init  

之后压缩文件夹ZLMediaKit,作为离线安装的ZLMediaKit

安装gcc

git_gcc_gcc-c++.zip包内容如下,可参考 https://blog.csdn.net/White_Black007/article/details/81357234 提取

 

 拷贝程序包git_gcc_gcc-c++.zip到服务器

执行以下命令进行安装

#解压缩

unzip git_gcc_gcc-c++.zip

cd git_gcc_gcc-c++

#安装

 rpm -Uvh *.rpm --nodeps --force

#验证

gcc  --version

安装cmake

下载地址   https://cmake.org/files/v3.26/ 

拷贝文件cmake-3.26.3-linux-x86_64.tar.gz到服务器

# 1.解压缩包,并将其移动到/opt 目录下 

tar -xf cmake-3.26.3-linux-x86_64.tar.gz

mv cmake-3.26.3-linux-x86_64 /opt/cmake-3.26.3 

# 2.建立软连接

sudo ln -sf /opt/cmake-3.26.3/bin/* /usr/bin/ 

# 3.执行命令查看版本

cmake --version

安装openssl

下载地址 https://www.openssl.org/source/

拷贝程序包openssl-1.1.1w.tar.gz到服务器

#解压缩

tar -zvxf openssl-1.1.1w.tar.gz

cd openssl-1.1.1w

#设定OpenSSL安装目录

./config --prefix=/usr/local/openssl

#编译 也可执行make -j4  提高编译速度

make

#安装

make install

#创建符号链接

sudo ln -s /usr/local/openssl/lib/libcrypto.so.1.1   /usr/lib64/libcrypto.so.1.1

sudo ln -s /usr/local/openssl/lib/libssl.so.1.1   /usr/lib64/libssl.so.1.1

#执行命令查看版本

openssl version

注:

执行./config --prefix=usr/local/openssl  时报错

 是由于 --prefix 后面必须时绝对路径,已经更改为./config --prefix=/usr/local/openssl,而不是 ./config --prefix=usr/local/openssl

 源码编译

拷贝文件ZLMediaKit.zip到服务器

 

# 解压缩包

unzip ZLMediaKit.zip

cd ZLMediaKit

mkdir build

cd build

cmake ..

make -j4

 

运行

编译完文件位置 ZLMediaKit/release/linux/Debug/

#增加权限

cd /home/sa/ZLMediaKit/release/linux/Debug/

chmod 777 MediaServer

#直接运行

./MediaServer
#或

#以守护进程运行

./MediaServer   -d  &