溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CentOS下安裝Nginx實例分析

發(fā)布時間:2022-06-02 11:48:27 來源:億速云 閱讀:111 作者:iii 欄目:大數(shù)據(jù)

這篇文章主要介紹“CentOS下安裝Nginx實例分析”,在日常操作中,相信很多人在CentOS下安裝Nginx實例分析問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”CentOS下安裝Nginx實例分析”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

安裝環(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)容粘貼進 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,如果和上面紅色部分匹配,再輸入 y 確認

5、啟動 | 停止 | 重啟 nginx:

# 啟動
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

到此,關(guān)于“CentOS下安裝Nginx實例分析”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI