CentOS7 nginx安裝與解除安裝
阿新 • • 發佈:2020-07-21
一、安裝
1.1 新增Nginx儲存庫
要新增CentOS EPEL倉庫,終端使用yum命令安裝,直接複製執行:
- yum -y install epel-release
1.2 安裝Nginx
現在Nginx儲存庫已經安裝在您的伺服器上,使用以下yum
命令安裝Nginx:
- yum -y install nginx
1.3 啟動Nginx
Nginx不會自動啟動.要執行Nginx,請輸入:
- systemctl start nginx
1.4 設定防火牆
- ## 允許http通訊
- firewall-cmd --permanent --zone=public --add-service=http
- ## 允許https通訊
- firewall-cmd --permanent --zone=public --add-service=https
- ## 重啟防火牆
- firewall-cmd --reload
1.5 測試
瀏覽器裡鍵入你的主機地址
如果看到這個頁面,那麼你的Web伺服器現在已經正確安裝了。
如果想在系統啟動時啟用Nginx。請輸入以下命令:
- systemctl enable nginx
恭喜你!!! Nginx現在已經成功安裝並允許了!!
二 . 解除安裝
1 停止Nginx軟體
- service nginx stop
2 刪除Nginx的自動啟動
- chkconfig nginx off
3 從源頭刪除Nginx
- rm -rf /usr/sbin/nginx
- rm -rf /etc/nginx
- rm -rf /etc/init.d/nginx
4 再使用yum清理
- yum remove nginx
推薦:鋅聞網