一、nginx配置
新建文件夹以放置文件
mkdir nginx
cd nginx
下载nginx
wget http://nginx.org/download/nginx-1.19.0.tar.gz
下载nginx-rtmp-module
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
解压缩
tar -zxvf nginx-1.19.0.tar.gz
unzip master.zip
下载pcre
wget http://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
tar zxvf pcre-8.45.tar.gz
cd pcre-8.45
sudo ./configure
sudo make
sudo make install
到此PCRE安装完毕,可以使用pcre-config --version命令查看版本号验证是否安装成功
安装依赖包
apt-get install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g zlib1g-dev
# Ubuntu14.04的仓库中没有发现openssl-dev,由下面openssl和libssl-dev替代
apt-get install openssl openssl-dev
#如果没有上述两个包的话:
#sudo apt-get install openssl
#sudo apt-get install libssl-dev
安装nginx
sudo ./configure --with-http_stub_status_module --with-http_ssl_module --with-pcre=../pcre-8.45 --add-module=../nginx-rtmp-module-master
sudo make
sudo make install
配置nginx.conf
cd /usr/local/nginx/conf
vi nginx.conf
加到末尾
rtmp {
server {
listen 1935;
application live {
live on;
}
}
}
启动nginx
cd /usr/local/nginx/sbin
./nginx
停止nginx
cd /usr/local/nginx/sbin
./nginx -s stop
cd /usr/local/nginx/sbin
./nginx -t -c ../conf/nginx.conf
./nginx -s reload
二、nms配置
mkdir nms
cd nms
npm install node-media-server
cd node_modules
touch app.js
vi app.js
输入
const NodeMediaServer = require('node-media-server');
const config = {
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60
},
http: {
port: 8000,
allow_origin: '*'
}
};
var nms = new NodeMediaServer(config)
nms.run();
运行
node app.js