安裝環境:linux 伺服器centos 7.3、root 權限
1、install the prerequisites:
sudo yum install yum-utils
2 、to set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
#(注意替換os 版本:$releasever,如centos 版本是7,就替換成7)
指令:
使用vim 編輯nginx.repo 檔案
vim /etc/yum.repos.d/nginx.repo
設定nginx 的yum 來源:
將以下內容貼進nginx.repo 檔案中
[nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true
輸入vim指令:wq 儲存並退出
3、to install nginx, run the following command:
sudo yum install nginx
中途會輸入y 確認安裝
4、when prompted to accept the gpg key, verify that the fingerprint matches 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62, and if so, accept it.
最後會輸出fingerprint,如果和上面紅色部分匹配,再輸入開始 確認啟動
#5、啟動| 停止| 重啟nginx:# 启动 systemctl start nginx.service # 停止 systemctl stop nginx.service # 重启 systemctl restart nginx.service
rpm -ql nginx
/etc/nginx/conf.d /etc/nginx/conf.d/default.conf
以上是CentOS下安裝Nginx實例分析的詳細內容。更多資訊請關注PHP中文網其他相關文章!