CentOS7 nginx安裝與卸載

本教程中的步驟要求用戶擁有root權限

一.  安裝

 1.1:添加Nginx存儲庫

         要添加CentOS EPEL倉庫,終端使用yum命令安裝,直接複製執行:nginx

sudo yum -y install epel-release

 

1.2:安裝Nginx

       如今Nginx存儲庫已經安裝在您的服務器上,使用如下yum命令安裝Nginx :瀏覽器

sudo yum -y install nginx

1.3:啓動Nginx

  Nginx不會自動啓動.要運行Nginx,請輸入:服務器

sudo systemctl start nginx

  若是您正在運行防火牆,請運行如下命令以容許HTTP和HTTPS通訊:(若是防火牆關了,可直接跳過)測試

1.4:設置防火牆

 1.4.1:容許http通訊
sudo firewall-cmd --permanent --zone=public --add-service=http
1.4.2:容許https通訊
sudo firewall-cmd --permanent --zone=public --add-service=https
1.4.3:重啓防火牆
sudo firewall-cmd --reload

1.5:測試

  瀏覽器裏鍵入你的主機地址spa

 

  若是看到這個頁面,那麼你的Web服務器如今已經正確安裝了。code

  若是想在系統啓動時啓用Nginx。請輸入如下命令:blog

sudo 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

   ok結束。rem

原創內容,轉載請註明出處,以爲不錯點個贊哦!!!!!cmd

相關文章
相關標籤/搜索