官方文檔:https://nginx.org/en/linux_packages.html#RHEL-CentOS
安裝環(huán)境:Linux 服務(wù)器 CentOS 7.3、Root 權(quán)限
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
設(shè)置 Nginx 的 yum 源:
將以下內(nèi)容粘貼進(jìn) 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
中途會(huì)輸入 y 確認(rèn)安裝
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.
最后會(huì)輸出 fingerprint,如果和上面紅色部分匹配,再輸入 y 確認(rèn)
5、啟動(dòng) | 停止 | 重啟 Nginx:
# 啟動(dòng) systemctl start nginx.service # 停止 systemctl stop nginx.service # 重啟 systemctl restart nginx.service
6、查看 Nginx 所有安裝位置:
rpm 是 linux 的 rpm 包管理工具,-q 代表詢問模式,-l 代表返回列表
rpm -ql nginx
7、Nginx 配置文件:
/etc/nginx/conf.d /etc/nginx/conf.d/default.conf
總結(jié)
以上所述是小編給大家介紹的CentOS下 安裝 Nginx的方法,希望對大家有所幫助!
標(biāo)簽:臺(tái)灣 中衛(wèi) 興安盟 大慶 清遠(yuǎn) 安陽 雅安 長治
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《CentOS下 安裝 Nginx的方法》,本文關(guān)鍵詞 CentOS,下,安裝,Nginx,的,方法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。