首頁 > 運維 > Nginx > 主體

CentOS下安裝Nginx實例分析

PHPz
發布: 2023-05-11 20:28:11
轉載
871 人瀏覽過

安裝環境: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
登入後複製

6、查看nginx 所有安裝位置:

rpm 是linux 的rpm 套件管理工具,-q 代表詢問模式,-l 代表返回列表

rpm -ql nginx

7、nginx 設定檔:

/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
登入後複製

以上是CentOS下安裝Nginx實例分析的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!