树莓派rtmp服务器搭建

首先需要下载

nginx-1.8.1 : http://nginx.org/download/nginx-1.8.1.tar.gz

nginx-rtmp-module : https://github.com/arut/nginx-rtmp-module

安装nginx
1.安装nginx-1.8.1
wget http://nginx.org/download/nginx-1.8.1.tar.gz

2.安装依赖
安装 PCRE 正则依赖库
sudo apt-get install libpcre3 libpcre3-dev
下载openssl-1.0.1
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz

3.解压
tar -xvf nginx-1.8.1.tar.gz -C /usr/local/live

4.配置
//修改默认监听端口
vi conf/nginx.conf

5.添加nginx-rtmp-module模块并编译安装
将下载的nginx-rtmp-module文件解压,进入第3步解压完的nginx-1.8.1文件夹中

./configure --add-module=../nginx-rtmp-module --prefix=/usr/local/live/nginx
make
make install

在编译步骤出现如下错误:
cc1: all warnings being treated as errors
objs/Makefile:460: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/home/wzj/tools/nginx/nginx-1.11.3'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

解决办法
找到对应的Maakefile文件,将gcc参数中的-Werror去掉。
我上面显示的是./objs/Makefile文件,我打开看了下,将第三行的-Werror去掉就可以

6.运行nginx,进入第5步安装完后的nginx文件

./sbin/nginx

搭建流媒体服务器相关配置
1.继续上面的第4步
``
events {
worker_connections 1024;
}

//添加的部分
rtmp {
server {
listen 82;#之后推流拉流的端口
chunk_size 4096;

    application live {  
        live on;
    }
}

}

server {
listen 81;
server_name localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;
  
    #添加的部分
    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }
    location /stat.xsl {
        #为nginx-rtmp-module解压的地址
        root /usr/local/live/nginx-rtmp-module/;
    }
 
    location / {
        root   html;
        index  index.html index.htm;
    }
}

``
配置完成后重启nginx
./sbin/nginx -s reload

浏览器url: http:// + 服务器ip +: + 端口号 + /stat

这时候就可以试试推流给流媒体服务器了。

发布了240 篇原创文章 · 获赞 2 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/zhaocundang/article/details/104810931