下载ffmpeg推流工具
http://www.ffmpeg.org/download.html
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
zlib、PCRE、OpenSSL
Nginx、rtmp、openssl
nginx下载地址
http://nginx.org/en/download.html
下载版本
http://nginx.org/download/nginx-1.12.2.tar.gz
下载命令
wget http://nginx.org/download/nginx-1.12.2.tar.gz
openssl下载网页
https://www.openssl.org/source/
下载地址
https://www.openssl.org/source/openssl-1.0.2n.tar.gz
下载命令
wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
rtmp地址
https://github.com/arut/nginx-rtmp-module
下载地址
wget https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz
解压文件
tar -xzf OpenSSL_1_1_0g.tar.gz
编译openssl
找到openssl文件夹下config文件;指定生成文件目录,为当前目录下bin文件夹下,生成Makefile
./config —prefix=`pwd`/bin
编译Makefile
make install
编译openssl得到 libcrypto.so 和 libsso.so
https://github.com/arut/nginx-rtmp-module
编译nginx
#编译nginx-rtmp-module
#./configure —add-module=/path/to/nginx-rtmp-module 官方默认编译地址
#我的环境编译地址 ,生成makefile文件
#./configure —prefix=`pwd`/xieyuhai —add-module=/Users/xieyuhai/Documents/DN/nginx/nginx-rtmp-module-1.2.1
第二次编译centos7
./configure --prefix=`pwd`/xieyuhai --add-module=//root/newnginx/nginx-rtmp-module-1.2.0
——————————————————在/Users/xieyuhai/Documents/DN/nginx/nginx-1.12.2/auto/lib/openssl/config文件中添加下面脚本,相关地址酌情修改
if [ $ngx_found = no ]; then
# 自定义Mac路径
ngx_feature="OpenSSL library in /opt/local/"
#头文件路径
ngx_feature_path="/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/include"
#头文件路径
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/lib -L/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/bin/lib -lssl -lcrypto $NGX_LIBDL"
else
ngx_feature_libs="-L/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/lib -lssl -lcrypto $NGX_LIBDL"
fi
. auto/feature
fi
在nginx-1.12.2目录下,重新编译,生成Makefile
1、没有状态
./configure —prefix=`pwd`/xieyuhai —add-module=/Users/xieyuhai/Documents/DN/nginx/nginx-rtmp-module-1.2.1
2、添加了状态
./configure --prefix=`pwd`/xieyuhai --add-module=/root/nginx/nginx-rtmp-module-1.2.1 --with-http_stub_status_module
3、生成makefile后执行
make install
问题一、
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
问题二、
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.
安装openssl-devel解决问题
yum -y install openssl openssl-devel
执行Makefile
make install
执行成功会在当前目录生成xieyuhai文件夹
在这个目录下有一个nginx可执行文件
/root/nginx/nginx-1.12.2/xieyuhai/sbin/
在/etc/ld.so.conf文件中添加nginx生成的目录
#/root/nginx/nginx-1.12.2/xieyuhai
/root/newnginx/openssl-OpenSSL_1_1_0f/bin/lib
调用ldconfig命令,是上一步修改生效
启动nginx,
执行./nginx
停止nginx
./nginx -s stop
/root/nginx/nginx-1.12.2/xieyuhai/sbin
解决端口占用
sudo fuser -k 80 / tcp
开启nginx
./nginx
配置阿里云安全组
添加端口1935
将/root/newnginx/nginx-rtmp-module-1.2.0/test 目录下的nginx.conf 拷贝到nginx-1.12.2/xieyuhai/conf/目录下
cp nginx.conf /root/newnginx/nginx-1.12.2/xieyuhai/conf/
使用ffmpeg模拟推流
ffmpeg -re -i /Users/xieyuhai/Downloads/3d.mp4 -f flv rtmp://47.94.215.45/myapp/mystream
http://czmmiao.iteye.com/blog/1733722
创建文件,并编译
vim /etc/init.d/nginx
授权
chmod 755 /etc/init.d/nginx
chkconfig /etc/init.d/nginx
问题
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
ulimit -a,显示如下,将红色字的变量改为1024即可,使用命令ulimit -u 1024。
查看进程号
ps -ef|grep nginx
杀死进程
kill -QUIT 2072
强制停止
pkill -9 nginx
测试是否成功
./nginx -t
重启
./nginx -s reload
重启nginx服务
kill -HUP 进程号
查看nginx配置文件目录
nginx -t
添加状态开启
location /ngx_status{
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
配置完成后的nginx.conf文件
worker_processes 5;
user root;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application myapp {
live on;
#record keyframes;
#record_path /tmp;
#record_max_size 128K;
#record_interval 30s;
#record_suffix .this.is.flv;
#on_publish http://localhost:8080/publish;
#on_play http://localhost:8080/play;
#on_record_done http://localhost:8080/record_done;
}
}
}
http {
server {
listen 8089;
fastcgi_intercept_errors on;
#location / {
# root html;
# index index.html index.htm;
#}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# root /root/nginx/nginx-1.12.2/html;
root /root/nginx/nginx-rtmp-module-1.2.1;
#stat stat.xsl;
}
location /control {
rtmp_control all;
}
#location /publish {
# return 201;
#}
#location /play {
# return 202;
#}
#location /record_done {
# return 203;
#}
location /rtmp-publisher {
root /root/nginx/nginx-rtmp-module-1.2.1/test;
}
location / {
root /root/nginx/nginx-rtmp-module-1.2.1/test/www;
index index.html record.html;
}
#location /record {
# root /root/nginx/nginx-rtmp-module-1.2.1/test/www;
# record record.html;
#}
location /ngx_status{
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
}
}
http://www.ffmpeg.org/download.html
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
zlib、PCRE、OpenSSL
Nginx、rtmp、openssl
nginx下载地址
http://nginx.org/en/download.html
下载版本
http://nginx.org/download/nginx-1.12.2.tar.gz
下载命令
wget http://nginx.org/download/nginx-1.12.2.tar.gz
openssl下载网页
https://www.openssl.org/source/
下载地址
https://www.openssl.org/source/openssl-1.0.2n.tar.gz
下载命令
wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
rtmp地址
https://github.com/arut/nginx-rtmp-module
下载地址
wget https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz
解压文件
tar -xzf OpenSSL_1_1_0g.tar.gz
编译openssl
找到openssl文件夹下config文件;指定生成文件目录,为当前目录下bin文件夹下,生成Makefile
./config —prefix=`pwd`/bin
编译Makefile
make install
编译openssl得到 libcrypto.so 和 libsso.so
https://github.com/arut/nginx-rtmp-module
编译nginx
#编译nginx-rtmp-module
#./configure —add-module=/path/to/nginx-rtmp-module 官方默认编译地址
#我的环境编译地址 ,生成makefile文件
#./configure —prefix=`pwd`/xieyuhai —add-module=/Users/xieyuhai/Documents/DN/nginx/nginx-rtmp-module-1.2.1
第二次编译centos7
./configure --prefix=`pwd`/xieyuhai --add-module=//root/newnginx/nginx-rtmp-module-1.2.0
——————————————————在/Users/xieyuhai/Documents/DN/nginx/nginx-1.12.2/auto/lib/openssl/config文件中添加下面脚本,相关地址酌情修改
if [ $ngx_found = no ]; then
# 自定义Mac路径
ngx_feature="OpenSSL library in /opt/local/"
#头文件路径
ngx_feature_path="/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/include"
#头文件路径
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/lib -L/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/bin/lib -lssl -lcrypto $NGX_LIBDL"
else
ngx_feature_libs="-L/Users/xieyuhai/Documents/DN/nginx/openssl-1.0.2n/xieyuhai/lib -lssl -lcrypto $NGX_LIBDL"
fi
. auto/feature
fi
在nginx-1.12.2目录下,重新编译,生成Makefile
1、没有状态
./configure —prefix=`pwd`/xieyuhai —add-module=/Users/xieyuhai/Documents/DN/nginx/nginx-rtmp-module-1.2.1
2、添加了状态
./configure --prefix=`pwd`/xieyuhai --add-module=/root/nginx/nginx-rtmp-module-1.2.1 --with-http_stub_status_module
3、生成makefile后执行
make install
问题一、
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
问题二、
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.
安装openssl-devel解决问题
yum -y install openssl openssl-devel
执行Makefile
make install
执行成功会在当前目录生成xieyuhai文件夹
在这个目录下有一个nginx可执行文件
/root/nginx/nginx-1.12.2/xieyuhai/sbin/
在/etc/ld.so.conf文件中添加nginx生成的目录
#/root/nginx/nginx-1.12.2/xieyuhai
/root/newnginx/openssl-OpenSSL_1_1_0f/bin/lib
调用ldconfig命令,是上一步修改生效
启动nginx,
执行./nginx
停止nginx
./nginx -s stop
/root/nginx/nginx-1.12.2/xieyuhai/sbin
解决端口占用
sudo fuser -k 80 / tcp
开启nginx
./nginx
配置阿里云安全组
添加端口1935
将/root/newnginx/nginx-rtmp-module-1.2.0/test 目录下的nginx.conf 拷贝到nginx-1.12.2/xieyuhai/conf/目录下
cp nginx.conf /root/newnginx/nginx-1.12.2/xieyuhai/conf/
使用ffmpeg模拟推流
ffmpeg -re -i /Users/xieyuhai/Downloads/3d.mp4 -f flv rtmp://47.94.215.45/myapp/mystream
http://czmmiao.iteye.com/blog/1733722
创建文件,并编译
vim /etc/init.d/nginx
授权
chmod 755 /etc/init.d/nginx
chkconfig /etc/init.d/nginx
问题
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
ulimit -a,显示如下,将红色字的变量改为1024即可,使用命令ulimit -u 1024。
查看进程号
ps -ef|grep nginx
杀死进程
kill -QUIT 2072
强制停止
pkill -9 nginx
测试是否成功
./nginx -t
重启
./nginx -s reload
重启nginx服务
kill -HUP 进程号
查看nginx配置文件目录
nginx -t
添加状态开启
location /ngx_status{
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
配置完成后的nginx.conf文件
worker_processes 5;
user root;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application myapp {
live on;
#record keyframes;
#record_path /tmp;
#record_max_size 128K;
#record_interval 30s;
#record_suffix .this.is.flv;
#on_publish http://localhost:8080/publish;
#on_play http://localhost:8080/play;
#on_record_done http://localhost:8080/record_done;
}
}
}
http {
server {
listen 8089;
fastcgi_intercept_errors on;
#location / {
# root html;
# index index.html index.htm;
#}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# root /root/nginx/nginx-1.12.2/html;
root /root/nginx/nginx-rtmp-module-1.2.1;
#stat stat.xsl;
}
location /control {
rtmp_control all;
}
#location /publish {
# return 201;
#}
#location /play {
# return 202;
#}
#location /record_done {
# return 203;
#}
location /rtmp-publisher {
root /root/nginx/nginx-rtmp-module-1.2.1/test;
}
location / {
root /root/nginx/nginx-rtmp-module-1.2.1/test/www;
index index.html record.html;
}
#location /record {
# root /root/nginx/nginx-rtmp-module-1.2.1/test/www;
# record record.html;
#}
location /ngx_status{
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
}
}