nginx rtmpサーバの構築
5515 ワード
1、nginxをダウンロードして、住所http://nginx.org/en/download.html
2、nginx-rtmp-moduleをダウンロードし、https://github.com/arut/nginx-rtmp-module#example-nginxconf
3、こちらからダウンロードしたのは最新バージョンのnginx-1.10.3で、解凍してからnginx-1.10.3に入り、以下のコマンドを実行します.
rtmp/nginx-rtmp-module解凍のパス.
4、make&&make install
5、インストールが成功したら、開く
rtmp構成の追加
6、サーバーの起動
起動時に表示される可能性があります.
1、まずpcreソフトウェアがインストールされていることを確認する(nginxはこのソフトウェアに依存する)2、ソフト接続を作成する/lib/*32ビットシステムにとって:1#libライブラリを表示する2# ls/lib/|grep pcre 3 libpcre.so.04 libpcre.so.0.0.1 5#ソフト接続を追加6#ln-s/lib/libpcre.so.0.0.1/lib/libpcre.so.1/lib 64ビットシステムの場合:1#libライブラリを表示2# ls/lib 64/|grep pcre 3 libpcre.so.04 libpcre.so.0.0.1 5#ソフトコネクション6#ln-s/lib 64/libpcre.so.0.0.1/lib 64/libpcre.so.17を追加ffmpegを使用してコードストリームをプッシュ
ffmpeg -i rtsp://admin:[email protected] -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 96k -r 25 -b:v 500k -s 640*480 -f flv rtmp://172.16.51.106:1935/myapp/test1
VLCで再生:
rtmp://172.16.51.106:1935/myapp/test1
2、nginx-rtmp-moduleをダウンロードし、https://github.com/arut/nginx-rtmp-module#example-nginxconf
3、こちらからダウンロードしたのは最新バージョンのnginx-1.10.3で、解凍してからnginx-1.10.3に入り、以下のコマンドを実行します.
./configure --prefix=/usr/local/nginx --add-module=/home/samba/shb/rtmp/nginx-rtmp-module --with-http_ssl_module
/home/samba/shb/rtmp/nginx-rtmp-moduleはrtmp/nginx-rtmp-module解凍のパス.
4、make&&make install
5、インストールが成功したら、開く
vi /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application myapp {
live on;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
rtmp構成の追加
rtmp {
server {
listen 1935;
application myapp {
live on;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
}
}
6、サーバーの起動
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
起動時に表示される可能性があります.
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解決方法:1、まずpcreソフトウェアがインストールされていることを確認する(nginxはこのソフトウェアに依存する)2、ソフト接続を作成する/lib/*32ビットシステムにとって:1#libライブラリを表示する2# ls/lib/|grep pcre 3 libpcre.so.04 libpcre.so.0.0.1 5#ソフト接続を追加6#ln-s/lib/libpcre.so.0.0.1/lib/libpcre.so.1/lib 64ビットシステムの場合:1#libライブラリを表示2# ls/lib 64/|grep pcre 3 libpcre.so.04 libpcre.so.0.0.1 5#ソフトコネクション6#ln-s/lib 64/libpcre.so.0.0.1/lib 64/libpcre.so.17を追加ffmpegを使用してコードストリームをプッシュ
ffmpeg -i rtsp://admin:[email protected] -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 96k -r 25 -b:v 500k -s 640*480 -f flv rtmp://172.16.51.106:1935/myapp/test1
VLCで再生:
rtmp://172.16.51.106:1935/myapp/test1