Mac搭建nginx+rtmp服务器

一、安装Homebrow

  已经安装了brow的可以直接跳过这一步。

  执行命令

  ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  如果已经安装过,而想要卸载:

  ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

 

二、安装nginx

  1、先glone nginx项目到本地:

  brew tap homebrew/nginx

  2、 执行安装:

  brew install nginx-full --with-rtmp-module

 配置nginx的rtmp模块:

 3、查看安装到了哪里:

  brew info nginx-full

  执行结果:

 

   nginx安装所在位置为:/usr/local/Cellar/nginx-full/1.19.10/bin/nginx

   nginx配置文件所在位置为:/usr/local/etc/nginx/nginx.conf

三、运营nginx

  1、输入命令启动nginx服务:nginx

  2、浏览器输入:http://localhost:8080

  显示如下,则启动成功:

 

  3、nginx常用方法:

    重新加载配置文件:nginx -s reload

    重新加载日志:nginx -s reopen

    停止nginx:nginx -s stop

    有序退出nginx:nginx -s quit

四、配置rtmp

  修改nginx.conf这个配置文件,配置rtmp

  1、用记事本工具打开nginx.conf

  2、在http节点后面加上rtmp配置:

 rtmp {

 server {

 listen 1935;

 application rtmplive { 

live on;

max_connections 1024;

}

application hls{

live on;

hls on;

hls_path /usr/local/var/www/hls;

hls_fragment 1s;

}}}

 

 

 

 

 

 

 

 

posted @ 2021-11-12 11:30  凝心叶子  阅读(189)  评论(0编辑  收藏  举报