Nginx安装&升级&打补丁
主机环境
1:Centos7.9(最小化安装)
2:Nginx1.18.0,下载链接:http://nginx.org/download/nginx-1.18.0.tar.gz
Nginx安装
[root@nginx ~]
[root@nginx ~]
[root@nginx ~]
[root@nginx ~]
[root@nginx ~]
[root@nginx ~]
[root@nginx nginx-1.18.0]
[root@nginx app]
ln -s /app/nginx/sbin/nginx /usr/bin/nginx
Nginx配置
这里配置文件仅做参考,具体根据实际情况来
cat /app/nginx/conf/nginx.conf
user nginx;
worker_processes 1;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
nginx
echo nginx >> /etc/rc.local
chmod a+x /etc/rc.local
Nginx常用命令
ps -aux | grep nginx
nginx -t
nginx -c /app/nginx/conf/nginx.conf
nginx -s stop
nginx -s quit
nginx -s reload
nginx -s reload
Nginx热升级
tar -zxvf nginx-1.20.1.tar.gz -C /app
./configure --user=nginx --group=nginx --prefix=/app/nginx --with-http_ssl_module
make && make install
[root@nginx sbin]
nginx nginx.old
[root@nginx sbin]
root 9470 0.0 0.0 45976 1128 ? Ss 09:30 0:00 nginx: master process nginx
nginx 9471 0.0 0.1 46420 1884 ? S 09:30 0:00 nginx: worker process
root 9509 0.0 0.0 112812 976 pts/0 R+ 09:32 0:00 grep --color=auto nginx
kill -USR2 9470
kill -WINCH 9470
[root@nginx sbin]
root 9470 0.0 0.0 45976 1296 ? Ss 09:30 0:00 nginx: master process nginx
root 9511 0.0 0.1 45996 3128 ? S 09:35 0:00 nginx: master process nginx
nginx 9512 0.0 0.1 46452 1876 ? S 09:35 0:00 nginx: worker process
root 9514 0.0 0.0 112812 976 pts/0 S+ 09:35 0:00 grep --color=auto nginx
[root@nginx sbin]
nginx version: nginx/1.20.1
Nginx热回退
cp nginx.old nginx
kill -HUP 9470
kill -WINCH 9511
[root@nginx sbin]
root 9470 0.0 0.0 45976 1296 ? Ss 09:30 0:00 nginx: master process nginx
root 9511 0.0 0.1 45996 3128 ? S 09:35 0:00 nginx: master process nginx
nginx 9530 0.0 0.1 46420 1880 ? S 09:38 0:00 nginx: worker process
root 9532 0.0 0.0 112812 972 pts/0 R+ 09:38 0:00 grep --color=auto nginx
[root@nginx sbin]
nginx version: nginx/1.18.0
Nginx打补丁
这里以升级openssl为例
[root@nginx sbin]
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@nginx ~]
[root@nginx ~]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
[root@nginx openssl-1.1.1k]
OpenSSL 1.1.1k 25 Mar 2021
cd /app/nginx-1.18.0
./configure --user=nginx --group=nginx --prefix=/app/nginx --with-http_ssl_module --with-openssl=/usr/local/openssl
make && make install
|