Linux直播服务器搭建

作者: Peakmain | 来源:发表于2021-08-17 16:12 被阅读0次
  • 阿里云服务器最低版本即可。centos 7以上
  • 1、创建根目录
cd ~
mkdir rtmp
cd rtmp
  • 2、下载
yum install git -y
wget http://nginx.org/download/nginx-1.15.3.tar.gz
wget https://codeload.github.com/arut/nginx-rtmp-module/tar.gz/v1.2.1
nvm install v11.6.0 
  • 3、下载nvm是node版本控制器
git clone git://github.com/creationix/nvm.git ~/nvm
//设置nvm自动运行
echo "source ~/nvm/nvm.sh" >> ~/.bashrc
source ~/.bashrc
  • 4、解压
tar xvf v1.2.1
tar xvf nginx-1.15.3.tar.gz
  • 5、安装git工具
yum install git
  • 6、 进入nginx目录
cd nginx-1.15.3
  • 7、安装pcre和openssl
    pcre
yum -y install pcre*

openssl

//openssl
yum -y install openssl*
  • 8、生成nginx安装文件
./configure --prefix=./bin --add-module=../nginx-rtmp-module-1.2.1
make instal
  • 9、cd到 cd bin/conf目录下
  • 10、配置
//修改默认监听端口
vim nginx.conf

参数

user root;
worker_processes 1;
error_log /usr/local/peakmain/rtmp/nginx-1.15.3/bin/logs/error.log debug;
events {
       worker_connections  1024;
   }

   rtmp {
       server {
           listen 1935;#之后推流拉流的端
           application live {
               live on;
          }
      }
  }
  http{
          server{

                  listen 8080;
                  server_name  localhost;
                  location /stat.xsl
                  {
                          root /usr/local/peakmain/rtmp/nginx-rtmp-module-1.2.1;
                  }

                  location /stat {
                          rtmp_stat all;
                          rtmp_stat_stylesheet stat.xsl;
                  }
                  location /control{
                          rtmp_control all;
                 }
                  location -publisher
                  { #注意目录
                          root /usr/local/peakmain/rtmp/nginx-rtmp-module-1.2.1/test;
                  }
                  location / {
                          #注意目录
                          root /usr/local/peakmain/rtmp/nginx-rtmp-module-1.2.1/test/www;
                           }
                }
}

  • 11、回到上两级,也就是nginx-1.15.3文件目录下
  • 12、运行nginx,进入第10安装完后的nginx文件
./bin/sbin/nginx -c conf/nginx.conf
  • 13、配置阿里云规则


    image.png
image.png
image.png
  • 14、浏览器访问: http:// + 服务器ip +: + 端口号,比如:11.15.23.251:8080


    image.png
  • 15、 http:// + 服务器ip +: + 端口号 + /stat 网页查看信息

相关文章

网友评论

    本文标题:Linux直播服务器搭建

    本文链接:https://www.haomeiwen.com/subject/wwrvbltx.html