1.下载
mkdir nginx_rtmpwget http://nginx.org/download/nginx-1.15.3.tar.gztar -zxvf nginx-1.15.3.tar.gzgit clone https://github.com/arut/nginx-rtmp-module
2. makefile生成
若没有则装置openssl。
--prefix是你的nginx的装置目录,留神批改成你本人的用户名。
将git clone的模块退出。
并指出openssl的地址(无需批改)。这一步仿佛大家都须要,mac没有本人找到这个库。
brew install opensslcd nginx-1.15.3./configure --prefix=/Users/{your username}/nginx --with-http_ssl_module --add-module=../nginx-rtmp-module --with-openssl=/usr/local/opt/openssl@1.1
若生成胜利,则会显示这样的summary
Configuration summary + using system PCRE library + using OpenSSL library: /usr/local/opt/openssl@1.1 + using system zlib library nginx path prefix: "/Users/ray/nginx" nginx binary file: "/Users/ray/nginx/sbin/nginx" nginx modules path: "/Users/ray/nginx/modules" nginx configuration prefix: "/Users/ray/nginx/conf" nginx configuration file: "/Users/ray/nginx/conf/nginx.conf" nginx pid file: "/Users/ray/nginx/logs/nginx.pid" nginx error log file: "/Users/ray/nginx/logs/error.log" nginx http access log file: "/Users/ray/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
3. make & make install
间接make会报错:
make -j8......... /Library/Developer/CommandLineTools/usr/bin/make -f objs/Makefilecd /usr/local/opt/openssl@1.1 \&& if [ -f Makefile ]; then /Library/Developer/CommandLineTools/usr/bin/make clean; fi \&& ./config --prefix=/usr/local/opt/openssl@1.1/.openssl no-shared no-threads \&& /Library/Developer/CommandLineTools/usr/bin/make \&& /Library/Developer/CommandLineTools/usr/bin/make install_sw LIBDIR=lib/bin/sh: ./config: No such file or directorymake[1]: *** [/usr/local/opt/openssl@1.1/.openssl/include/openssl/ssl.h] Error 127make: *** [build] Error 2
须要批改
sudo vim ./auto/lib/openssl/conf
把上面的几行中的.openssl去掉,而后保留
39 CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"40 CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"41 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"42 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
改成
39 CORE_INCS="$CORE_INCS $OPENSSL/include"40 CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"41 CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"42 CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
此时,须要从新执行第二步configure,再make胜利。
最初:
make install
4. 启动服务
cd /Users/{your username}/nginx sudo vim conf/nginx.conf
将上面的rtmp服务增加在最初(其中rtmplive能够自命名)
rtmp { server { listen 1935; application rtmplive { live on; } }}
而后启动服务
./sbin/nginx -c ./conf/nginx.conf
5. 测试
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/rtmplive/homeffplay -i. rtmp://localhost:1935/rtmplive/home
此时就能看到你推流的视频啦~
6. References
MAC上编译装置nginx-rtmp-module流媒体服务器