CentOS 7 下 NGINX 增加 nginx-module-vts 模块

CentOS 7 下 NGINX 增加 nginx-module-vts 模块

编译依赖安装
[root@lsr ~]# yum -y isntall zlib zlib-devel pcre pcre-devel openssl openssl-devel
nginx 下载
[root@lsr soft]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
nginx-module-vts 下载
[root@lsr soft]# git clone git://github.com/vozlt/nginx-module-vts.git
解压 nginx
[root@lsr soft]# tar zxf nginx-1.18.0.tar.gz
预编译
[root@lsr nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --add-module=../nginx-module-vts
编译 && 安装
[root@lsr nginx-1.18.0]# make -j 4 && make -j 4 install
验证可用模块
[root@lsr ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
configure arguments: --prefix=/usr/local/nginx --add-module=../nginx-module-vts
OpenSSL 生成加密文件
# 方法一 -- 面交互方式
[root@lsr ~]# printf "vts_user:$(openssl passwd -crypt 1234567890)\n" > /usr/local/nginx/conf/nginx_vts.db

# 方法二 -- 交互方式
[root@lsr ~]# htpasswd -cm ./nginx_vts.db vts_user
New password: 
Re-type new password: 
Adding password for user vts_user
nginx.conf 配置
http {
    include       mime.types;
    default_type  application/octet-stream;

	# 配置 vts 使用
    vhost_traffic_status_zone;
    
	server {
        listen       80;
        server_name  localhost;
        
        location / {
            root   html;
            index  index.html index.htm;

            # auth Setting
            auth_basic  "Add Auth For VTS";
            auth_basic_user_file /usr/local/nginx/conf/nginx_vts.db;
        }

        location /vts {

            # vhost Setting
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
        }
        
	}
	
}
# NGINX 出现 403 Forbidden 问题
	- 站点目录没有 NGINX 用户的访问权限
	- 配置文件里没有配置默认首页参数(index.html)
	- 配置文件里有配置默认首页参数,但站点目录下没有指定参数文件
	- 配置文件里设置了 allow、deny 等权限控制,导致客户端没有访问权限
启动 NGINX
[root@lsr conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
浏览器验证

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

参考

部署nginx及安装nginx-http-flv-module模块的流程如下: 1. 安装编译工具和依赖库 在终端输入以下命令: ``` yum install gcc gcc-c++ autoconf automake make zlib zlib-devel openssl-devel pcre-devel ``` 2. 下载nginxnginx-http-flv-module源码 在终端输入以下命令: ``` wget http://nginx.org/download/nginx-1.18.0.tar.gz wget https://github.com/winshining/nginx-http-flv-module/archive/master.zip ``` 3. 解压源码包 在终端输入以下命令: ``` tar -zxvf nginx-1.18.0.tar.gz unzip master.zip ``` 4. 进入nginx源码目录并配置 在终端输入以下命令: ``` cd nginx-1.18.0 ./configure --prefix=/usr/local/nginx --add-module=../nginx-http-flv-module-master ``` 5. 编译和安装 在终端输入以下命令: ``` make make install ``` 6. 启动nginx 在终端输入以下命令: ``` /usr/local/nginx/sbin/nginx ``` 7. 验证nginx是否安装成功 在浏览器中输入服务器IP地址,如果出现欢迎页面,说明nginx已经安装成功。 8. 配置nginx-http-flv-module 打开nginx配置文件,一般路径为/usr/local/nginx/conf/nginx.conf,在http块中添加以下内容: ``` http { flv { server { listen 8080; # flv 直播流地址 location /live { flv_live on; # flv 直播流地址 flv_stream_name live; } # flv 点播流地址 location /vod { flv; # flv 点播流地址,需根据实际情况修改 root /usr/local/nginx/html; } } } } ``` 9. 重启nginx 在终端输入以下命令: ``` /usr/local/nginx/sbin/nginx -s reload ``` 现在,nginx-http-flv-module模块已经成功安装并配置完成。可以使用流媒体播放器访问服务器IP地址,播放flv视频。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值