因为要用rtmp,所以重装了Nginx,导致Nginx的配置丢失了。
而且rtmp占用了原本phpMyAdmin的1935端口,修改过后也没用。
服务器内查询端口,没有发现修改过后的端口。
原本的配置是
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location ~ /tmp/ {
return 403;
}
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}
重装后的配置是:
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
rtmp {
server {
listen 1939;
application live {
live on;
hls on;
hls_path /www/wwwroot/rtmp.com;
}
}
}
stream {
log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
access_log /www/wwwlogs/tcp-access.log tcp_format;
error_log /www/wwwlogs/tcp-error.log;
include /www/server/panel/vhost/nginx/tcp/*.conf;
}
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 1939;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location ~ /tmp/ {
return 403;
}
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /root/nginx-rtmp-module/;
}
location /live {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /www/wwwroot/test.sshouxin.xyz;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
}
include /www/server/panel/vhost/nginx/*.conf;
}
左边是用了rtmp的 右边是原来的
用回原来的配置就能进去了。
原因出在修改的时候把phpMyAdmin的端口挪用了。
修改phpMyAdmin的端口会把配置的端口弄乱。
最终处理:
基于宝塔nginx安装Nginx-rtmp-module搭建hls直播 - Linux面板 - 宝塔面板论坛
https://www.bt.cn/bbs/thread-33703-1-1.html
在原来的配置上添加
events块下面:
include rtmp.conf;
server块下面:
include hls.conf;
两个新增的文件在:
/www/server/nginx/conf
rtmp.conf:
rtmp_auto_push on;
rtmp {
server {
listen 1935;
ping 30s;
chunk_size 4000;
notify_method get;
application hls {
live on;
hls on;
hls_path /www/wwwroot/rtmp.com; //这个是通过宝塔新建的网站的目录
hls_sync 100ms;
hls_fragment 5s;
}
application live {
live on;
}
# Video on demand
#application vod {
# play /www/tmp/Videos;
#}
# Video on demand over HTTP
#application vod_http {
# play http://localhost:8080/vod/;
#}
}
}
hls.conf:
server {
listen 1936;
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root html;
expires -1;
}
}
推流地址:
rtmp://192.168.1.139:1935/live/room
其中live是rtmp.conf里面application的名称
记得打开1935端口
nginx -s reload
重载配置 就都能用了
错误
重启服务器后Nginx不能启动
手动重启提示:
删掉rtmp配置的第一行还是报错
不引用rtmp模块则可以启动nginx
检查一下rtmp模块是否还存在 nginx -V