nginx平滑升级与location修饰符

nginx平滑升级与location修饰符


文章目录

  • nginx平滑升级与location修饰符
    • 一、nginx平滑升级
      • 1、部署nginx
      • 2、获取之前安装nginx的编译参数
      • 3、下载新模块
      • 4、重新编译软件
      • 5、备份源程序并停止、覆盖、启动服务
      • 6、测试--引用echo模块
    • 二、location案例

一、nginx平滑升级


1、部署nginx

//创建系统用户nginx
[root@10 ~]# useradd -r -M -s /sbin/nologin nginx

//安装依赖环境
[root@10 ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@10 ~]# yum -y groups mark install 'Development Tools'


//创建日志存放目录
[root@10 ~]# mkdir -p /var/log/nginx
[root@10 ~]# chown -R nginx.nginx /var/log/nginx
[root@10 ~]#


//下载nginx
[root@10 ~]# cd /usr/src/
[root@10 src]# wget http://nginx.org/download/nginx-1.22.0.tar.gz
--2022-10-10 14:15:30--  http://nginx.org/download/nginx-1.22.0.tar.gz
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073322 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.22.0.tar.gz’

nginx-1.22.0.tar.gz                       100%[====================================================================================>]   1.02M   301KB/s    in 3.5s

2022-10-10 14:15:34 (301 KB/s) - ‘nginx-1.22.0.tar.gz’ saved [1073322/1073322]

[root@10 src]#

//编译安装
[root@10 src]# ls
debug  kernels  nginx-1.22.0.tar.gz
[root@10 src]# tar xf nginx-1.22.0.tar.gz
[root@10 src]# cd nginx-1.22.0
[root@10 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 \
> --http-log-path=/var/log/nginx/access.log \
> --error-log-path=/var/log/nginx/error.log

[root@10 nginx-1.22.0]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install


//配置环境变量
[root@10 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@10 

你可能感兴趣的:(nginx,运维,服务器)