本人是在腾讯云ubuntu18上面编译的,zlm编译其实很简单,其实按照github上面的步骤编译一般都能成功,其中如果开启WebRtc的话需要libsrtp库和openssl库,其中openssl需要更新否则会出现各种问题,再次记录一下编译步骤,以供开发者参考,有什么不对的地方希望在下面留言~~
一.编译openssl
1:删除已有的openssl
sudo apt-get romove openssl
2:安装openssl
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xvzf openssl-1.1.1k.tar.gz
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
sudo make && make install
sudo echo "/usr/local/lib64/" >> /etc/ld.so.conf.d/libc.conf
sudo echo "/usr/local/openssl/lib" >> /etc/ld.so.conf.d/libc.conf
sudo ldconfig
sudo ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl # 替换系统openssl,非必须
openssl version -a
其中 echo 那两步是必须的 否则openssl找不到lib ubuntu和centos写入文件不一致 如果是centos需要写入对应的文件
二.安装libsrtp
git clone https://github.com/cisco/libsrtp.git
cd libsrtp
./configure --enable-openssl --with-openssl-dir=/usr/local/openssl
make -j8 && make install
三.编译ZLM
1.下载源码
#国内用户推荐从同步镜像网站gitee下载
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
#千万不要忘记执行这句命令
git submodule update --init
2.编译
cd ZLMediakits
mkdir build
cd build
cmake .. -DENABLE_WEBRTC=true -DOPENSSL_ROOT_DIR=/usr/local/openssl -DOPENSSL_LIBRARIES=/usr/local/openssl/lib
cmake --build . --target MediaServer
编译过程如图:
4.运行
cd ZLMediaKit/release/linux/Debug
#通过-h可以了解启动参数
./MediaServer -h
#以守护进程模式启动
./MediaServer -d &
至此已经完成zlm项目编译完成,其实zlm编译相对于其他开源流媒体服务简单,毕竟依赖环境相对于比较少,希望zlm项目使用的越来越少,功能越来越强大。
ZLM GitHub地址:https://github.com/ZLMediaKit/ZLMediaKit