centos7下安装RTMP(实时消息传输协议)服务

先安装git

yum install -y epel-release

rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm

yum list git2u

yum install -y git2u

git –version

 

进入nginx安装目录

cd /opt/software/nginx-1.7.9

用git下载nginx-rtmp-module

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

安装包会下载到/opt/software/nginx-1.7.9/nginx-rtmp-module

 开始安装nginx-rtmp-module

./configure --add-module=./nginx-rtmp-module

make

sudo make install

 

cd /usr/local/nginx

./sbin/nginx   启动nginx

停止nginx命令:./sbin/nginx -s stop

 

修改/usr/local/nginx下的nginx.conf文件,加RTMP实时消息传输协议服务Real Time Messaging Protocol

rtmp {

    server {

        listen 1935;

        chunk_size 4096;

        application vod {

            play /opt/data/www/resources/video; #这个目录下的视频文件可以用VLC player播放

        }

       application live2 {

            live on; # 开启直播

        }

    }

}

server {

        listen       80;

        server_name  192.168.1.105;

        location /stat {

            rtmp_stat all;

            rtmp_stat_stylesheet stat.xsl;

        }

        location /stat.xsl {

                    root /opt/software/nginx-1.7.9/nginx-rtmp-module; # stat.xsl文件在这个目录下

        }

        location / {

            root   /data/www/resources;

            index  index.html index.htm;

        }

}

重启nginx命令:./sbin/nginx -s reload

Nginx 403 forbidden的解决办法:如果在root   /data/www/resources;目录里没有index.html的时候,直接访问域名,找不到文件,会报403 forbidden

 

posted @ 2018-02-09 17:29  涓水之子  阅读(349)  评论(0)    收藏  举报