rtmp服务器创建和设置

1,安装ubuntu 16.4 依赖

sudo apt-get update
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev libtool libpcrecpp0v5 openssl -y

2,安装nginx1.14.2

2.1 下载软件

wget http://nginx.org/download/nginx-1.14.2.tar.gz

2.2 解压软件到当前目录    

tar xvf nginx-1.14.2.tar.gz

3,下载nginx-rtmp-module  

git clone https://github.com/adwpc/nginx-rtmp-module.git

4,配置nginx

./configure --sbin-path=/usr/local/nginx/nginx --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-stream --with-mail=dynamic --add-module=../nginx-rtmp-module

5,修改makefile文件,查找并删除“-Werror“字符串

vim nginx-1.14.2/objs/Makefile

6,编译并安装Nginx

make
make install

7,修改nginx.conf文件,添加rmtp支持

rtmp {
    server {
        listen 1935;

        application live {
            live on;
        }
        
        application hls {
            live on;
            hls on;  
            hls_path temp/hls;  
            hls_fragment 8s;  
        }
    }
}

8,运行nginx

cd /usr/local/nginx/
./nginx

9,如果提示创建temp/hls失败,手动创建temp文件夹后,再次运行nginx

相关推荐