软件的不同版本,在使用起来都有可能带来不可预知的影响,因此需要统一整理,固定下来,不允许轻易变更。
在Nginx开源版官网,点击右侧download可以看到各个版本的Nginx,其中Mainline是抢先的主干版本(版本号是奇数),Stable是稳定版(版本号是偶数)
系统环境,软件版本
部署路径
/home/application/nginx
代码路径
/home/application/nginx/html
日志路径
/home/application/nginx/logs
配置文件路径
/home/application/nginx/conf/nginx.conf 【主配置】
/home/application/nginx/conf.d/*
ssl证书路径
/home/application/nginx/cert
wget http://nginx.org/download/nginx-1.24.0.tar.gz
安装依赖包,NGINX是C语言写的,pcre-devel支持正则表达式,openssl 开启加密
yum -y install gcc pcre-devel openssl-devel tar make
useradd -s /sbin/nologin nginx -M
启用 HTTP/2 模块;启用 SSL 模块;启用 Stub Status 模块;启用4 层TCP/UDP 代理模块;启用 Gzip 静态模块
/home/application/nginx
mkdir /home/application/nginx
tar -xf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure --prefix=/home/application/nginx --user=nginx --group=nginx --with-http_v2_module --with-http_ssl_module --with-http_stub_status_module --with-stream --with-http_gzip_static_module --pid-path=/home/application/nginx/nginx.pid
make && make install
vim /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStart=/home/application/nginx/sbin/nginx
ExecReload=/home/application/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable nginx
systemctl start nginx
systemctl reload nginx [重新加载配置文件,相当于 nginx -s reload]
wget https://nginx.org/download/nginx-1.26.2.tar.gz
tar xf nginx-1.26.2.tar.gz
[root@nginx ~]# nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/home/application/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-stream
cd nginx-1.26.2
./configure --prefix=/home/application/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-stream
make
mv /home/application/nginx/sbin/nginx /home/application/nginx/sbin/nginx-old
cp nginx-1.26.2/objs/nginx /home/application/nginx/sbin/
make upgrade
/home/application/nginx/sbin/ -v