1.下载nginx
#下载Nginx:
http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.15.3.tar.gz
tar xvf nginx-1.15.3.tar.gz
#下载rtmp-module模块:
wget https://codeload.github.com/arut/nginx-rtmp-module/tar.gz/v1.2.1
tar xvf v1.2.1
#进入 nginx 支持
cd nginx-1.15.3
nginx-1.15.3 文件夹里面 执行下面命令,--prefix=最终的成果, --add-module=管理rtmp模块
./configure --prefix=/home/ms/tools/nginx/nginx-1.15.3/bin --add-module=../nginx-rtmp-module-1.2.1 --with-http_flv_module --with-http_mp4_module
sudo make install 【安装刚刚生成更新的Makefile】
/bin/ 最终的成果 conf html logs sbin
如果上面报错了,可能需要安装一些中间内容:https://blog.csdn.net/z920954494/article/details/52132125
######################################我的前置操作###############################
sudo apt-get install openssl libssl-dev
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
#######################################end########################################
编译成功后,还需要写脚本:
编译成功后,会在/bin/ 最终的成果 conf html logs sbin
cd /conf
gedit nginx.conf
遇到的错误:
对nginx.conf 进行修改
#user nobody;
#启动nginx服务器就会报错,权限被拒绝
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#如果启动错误,这个就是错误日志详情
error_log logs/error.log debug
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
rtmp {
server {
#注意端口占用
listen 1935;
#如果不加,可能会失败
application myapp {
live on;
#丢弃闲置5s的连接
drop_idle_publisher 5s;
}
}
}
#下面就是为了测试 http://139.224.136.101:8080/stat 控制面板的意思
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;
# }
location / {
#注意目录
/home/ms/tools/nginx/nginx-rtmp-module-1.2.1/test/www;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl{
#注意目录
/home/ms/tools/nginx/nginx-rtmp-module-1.2.1/;
}
location /control{
rtmp_control all;
}
location /rtmp-publisher{
#注意目录
/home/ms/tools/nginx/nginx-rtmp-module-1.2.1/test;
}
#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;
# }
#}
}