nginx平滑升级及nginx配置文件
目录
nginx平滑升级并添加新功能
1.先获取老版本的编译信息
2.获取新版本安装包和功能包
3.配置新版本或功能,配置时加上老版本的编译参数,然后添加新功能模块
4.进行编译,编译完不进行安装操作
5.备份老版本程序,使用复制的方法。在停掉老版本程序的进程,将新版本程序复制到老版本所在位置直接替换掉老版本程序并启动新版本程序
//查看老版本编译信息
[root@nginx ~]# nginx -V
nginx version: nginx/1.20.2
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module
//准备好新版本安装包和功能包
[root@nginx ~]# wget http://nginx.org/download/nginx-1.22.0.tar.gz
[root@nginx ~]# yum -y install git
[root@nginx ~]# git clone https://gitee.com/Their-own/nginx_module_echo.git
[root@nginx ~]# ls
anaconda-ks.cfg nginx-1.20.2 nginx-1.20.2.tar.gz nginx-1.22.0 nginx-1.22.0.tar.gz nginx_module_echo
//解压并编译
[root@nginx ~]# tar xf nginx-1.22.0.tar.gz
[root@nginx ~]# cd nginx-1.22.0
[root@nginx nginx-1.22.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--add-module=../nginx_module_echo //添加新功能使用-add-module=模块目录位置
[root@nginx nginx-1.22.0]# make
[root@nginx nginx-1.22.0]# ls
CHANGES CHANGES.ru LICENSE Makefile README auto conf configure contrib html man objs src
[root@nginx nginx-1.22.0]# objs/nginx -v
nginx version: nginx/1.22.0
[root@nginx nginx-1.22.0]# nginx -v
nginx version: nginx/1.20.2
//一步到位
[root@nginx nginx-1.22.0]# cp /usr/local/nginx/sbin/nginx{,-bak};pkill nginx;\cp ./objs/nginx /usr/local/nginx/sbin/nginx;systemctl start nginx
[root@nginx nginx-1.22.0]# nginx -v
nginx version: nginx/1.22.0
[root@nginx nginx-1.22.0]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
nginx配置文件
主配置文件:/usr/local/nginx/conf/nginx.conf
默认启动nginx时,使用的配置文件是:安装路径/conf/nginx.conf文件
可以在启动nginx时通过-c选项来指定要读取的配置文件
nginx常见的配置文件及其作用
配置文件 | 作用 |
---|---|
nginx.conf | nginx的基本配置文件 |
mime.types | MIME类型关联的扩展文件 |
fastcgi.conf | 与fastcgi相关的配置 |
proxy.conf | 与proxy相关的配置 |
sites.conf | 配置nginx提供的网站,包括虚拟主机 |
nginx.conf配置详解
nginx.conf的内容分为以下几段:
- main配置段:全局配置段。其中main配置段中可能包含event配置段
- event {}:定义event模型工作特性
- http {}:定义http协议相关的配置
配置指令:要以分号结尾,语法格式如下:
derective value1 [value2 ...];
支持使用变量:
内置变量:模块会提供内建变量定义
自定义变量:set var_name value
用于调试、定位问题的配置参数
daemon {on|off}; //是否以守护进程方式运行nginx,调试时应设置为off
master_process {on|off}; //是否以master/worker模型来运行nginx,调试时可以设置为off
error_log 位置 级别; //配置错误日志
error_log里的位置和级别能有以下可选项:
位置 | 级别 |
---|---|
file stderr syslog:server=address[,parameter=value] memory:size | debug:若要使用debug级别,需要在编译nginx时使用–with-debug选项 info not |
首页 上一页 1 2 3 下一页 尾页 1/3/3 | |
【大 中 小】【打印】 【繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部】 | |
上一篇:DNS域名解析服务 | 下一篇:nginx访问控制,用户认证,配置ht.. |