1. 程式人生 > 實用技巧 >CentOS7 nginx安裝與解除安裝

CentOS7 nginx安裝與解除安裝

一、安裝

1.1 新增Nginx儲存庫

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

  1. yum -y install epel-release

1.2 安裝Nginx

現在Nginx儲存庫已經安裝在您的伺服器上,使用以下yum命令安裝Nginx:

  1. yum -y install nginx

1.3 啟動Nginx

Nginx不會自動啟動.要執行Nginx,請輸入:

  1. systemctl start nginx

1.4 設定防火牆

  1. ## 允許http通訊
  2. firewall-cmd --permanent --zone=public --add-service=http
  3. ## 允許https通訊
  4. firewall-cmd --permanent --zone=public --add-service=https
  5. ## 重啟防火牆
  6. firewall-cmd --reload

1.5 測試

瀏覽器裡鍵入你的主機地址

如果看到這個頁面,那麼你的Web伺服器現在已經正確安裝了。

如果想在系統啟動時啟用Nginx。請輸入以下命令:

  1. systemctl enable nginx

恭喜你!!! Nginx現在已經成功安裝並允許了!!

二 . 解除安裝

1 停止Nginx軟體

  1. service nginx stop

2 刪除Nginx的自動啟動

  1. chkconfig nginx off

3 從源頭刪除Nginx

  1. rm -rf /usr/sbin/nginx
  2. rm -rf /etc/nginx
  3. rm -rf /etc/init.d/nginx

4 再使用yum清理

  1. yum remove nginx

推薦:鋅聞網