前言
使用yum安裝nginx 1.21版本后戒劫,被檢測(cè)出來(lái)了一些漏洞传透,按照要求升級(jí)到1.24版本凄敢。
卸載nginx
0凉唐、卸載前記住 把nginx.conf文件復(fù)制一份庸追,重裝后直接替換配置即可。
1台囱、執(zhí)行命令淡溯,看nginx是否在運(yùn)行
ps -ef|grep nginx
2、先停止nginx服務(wù):
sudo systemctl stop nginx
3簿训、執(zhí)行nginx依賴卸載命令
yum remove nginx
4咱娶、查詢nginx所在位置
whereis nginx 或者 find / -name nginx
5米间、刪除命令 后面跟以上目錄 全部刪掉,用步驟4的命令再測(cè)試一下,沒有了 就說明卸載干凈了膘侮。
rm -rf
升級(jí)nginx 至1.24.0 源碼安裝方式
1屈糊、下載一個(gè)安裝包 nginx-1.24.0.tar.gz。
2喻喳、創(chuàng)建源碼存放目錄,目錄可隨意
mkdir -p /soft/src
3、將下載的壓縮包 nginx-1.24.0.tar.gz復(fù)制到這個(gè)目錄困曙,或者cd到這個(gè)目錄表伦,直接wget url命令
4、cd 到 /soft/src目錄慷丽,執(zhí)行解壓命令
[root@localhost src]# tar xf nginx-1.24.0.tar.gz
[root@localhost src]# cd nginx-1.24.0/
5蹦哼、在解壓后的目錄中執(zhí)行以下命令,配置安裝的變量,--prefix指定的是安裝的目錄
[root@localhost nginx-1.24.0]# ./configure --prefix=/usr/local/nginx-1.24.0
5.5要糊、檢查是否成功
[root@localhost nginx-1.22.1]# echo $?
0
6纲熏、執(zhí)行完了后,再執(zhí)行make和 make install 命令
[root@localhost nginx-1.24.0]# make
[root@localhost nginx-1.24.0]# make install
7锄俄、轉(zhuǎn)到安裝目錄 /usr/local/nginx-1.24.0/conf目錄局劲,替換開始保存的備份配置文件
8、轉(zhuǎn)到目錄 /usr/local/nginx-1.24.0/sbin目錄下奶赠,執(zhí)行./nginx命令啟動(dòng)鱼填,nginx
停止也在這個(gè)目錄下面執(zhí)行 nginx -s stop
9、測(cè)試
ps aux | grep nginx