nginx安装_万金油_新浪博客

[root@proxy ~]# yum -y install  gcc pcre-devel openssl-devel   //可以写一个脚本
[root@proxy ~]# useradd -s /sbin/nologin  nginx
不是由超级管理员,启动服务,这样会更加安全,如果用root启动软件,软件就会获得超级管理员权限

[root@proxy ~]# id apache
id: apache: no such user
[root@proxy ~]# id nginx
uid=1001(nginx) gid=1001(nginx) 组=1001(nginx)


[root@proxy ~]# tar -xf nginx-1.12.2.tar.gz 
[root@proxy ~]# ls
anaconda-ks.cfg       nginx-1.12.2         公共  视频  文档  音乐
initial-setup-ks.cfg  nginx-1.12.2.tar.gz  模板  图片  下载  桌面
[root@proxy ~]# cd nginx-1.12.2/
[root@proxy nginx-1.12.2]# ./configure  \
> --prefix=/usr/local/nginx \       //指定安装路径(这也是默认位置)
> --user=nginx  \                          //指定用户
> --group=nginx  \                        //指定组
> --with-http_ssl_module             //指定模块

nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

安装时如果有报错,提示依赖包,提示一个就装一个
[root@proxy ~]# yum list  | grep  pcre  //查看依赖包
devel  //红帽系统,如果devel都是依赖包


[root@proxy nginx-1.12.2]# make && make install




2)nginx命令的用法

 
    
  1. [root@proxy ~]# /usr/local/nginx/sbin/nginx                    //启动服务
  2. [root@proxy ~]# /usr/local/nginx/sbin/nginx -s stop            //关闭服务
  3. [root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload        //重新加载配置文件
  4. [root@proxy ~]# /usr/local/nginx/sbin/nginx –V                //查看软件信息
  5. [root@proxy ~]# ln -s /usr/local/nginx/sbin/nginx /sbin/        //方便后期使用
[root@proxy ~]# ls /usr/local/nginx/
client_body_temp  fastcgi_temp   logs         sbin       uwsgi_temp
conf              html          proxy_temp  scgi_temp

conf      配置文件       html 网页       logs日志      sbin 主程序

[root@proxy ~]# ls /usr/local/nginx/sbin/   //启动服务手动起
nginx

确认是否启动的方法:
[root@proxy ~]# ss -ntulp |grep nginx
[root@proxy ~]# firefox  http:192.168.4.5

















要在 Nginx安装 ngx_http_mp4_module 模块,需要按照以下步骤进行操作: 1. 确认 Nginx 是否支持 ngx_http_mp4_module 模块 首先需要确认 Nginx 是否支持 ngx_http_mp4_module 模块,可以使用以下命令查看 Nginx 是否已经编译了该模块: ``` nginx -V 2>&1 | grep -o with-http_mp4_module ``` 如果输出结果为 with-http_mp4_module,则说明 Nginx 已经编译了 ngx_http_mp4_module 模块;如果输出结果为空,则说明 Nginx 没有编译该模块。 2. 下载 ngx_http_mp4_module 模块 如果 Nginx 没有编译 ngx_http_mp4_module 模块,需要下载该模块并添加到 Nginx 中。可以从 Github 上下载该模块,链接为:https://github.com/kaltura/nginx-vod-module。 可以使用以下命令将 ngx_http_mp4_module 模块下载到 /opt 目录下: ``` cd /opt git clone https://github.com/kaltura/nginx-vod-module.git ``` 3. 编译 Nginx 并添加 ngx_http_mp4_module 模块 在编译 Nginx 时需要添加 --add-module=/opt/nginx-vod-module 参数来指定 ngx_http_mp4_module 模块所在的目录,具体命令如下: ``` ./configure --prefix=/usr/local/nginx --add-module=/opt/nginx-vod-module make make install ``` 4. 配置 NginxNginx 的配置文件中添加以下内容,即可使用 ngx_http_mp4_module 模块: ``` location /video/ { mp4; mp4_buffer_size 1m; mp4_max_buffer_size 5m; } ``` 其中,/video/ 是视频文件所在的目录。mp4 是 ngx_http_mp4_module 模块提供的指令,表示该目录下的文件都是 MP4 格式的视频文件。 mp4_buffer_size 和 mp4_max_buffer_size 是 ngx_http_mp4_module 模块提供的两个参数,用于控制视频文件的缓存大小。 5. 重启 Nginx 完成以上步骤后,需要重启 Nginx 使配置生效: ``` nginx -s reload ``` 至此,ngx_http_mp4_module 模块安装完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维螺丝钉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值