CentOs8 Nginx(stable版)をインストール

CentOs8 Nginx(stable版)をインストール

「mainline」ブランチの方 が基本的に安定しているとされているが、今回は「stable」ブランチの方のインストールしてみる

CentOs8バージョン

#cat /etc/centos-release
CentOS Linux release 8.0.1905 (Core)

リポジトリ登録

こちらを参考に

## 編集
vi /etc/yum.repos.d/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

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

インストール

## インストール
yum --disablerepo=AppStream install -y nginx

## バージョン確認
nginx -v

<出力結果>
nginx version: nginx/1.16.1

## 起動 自動起動
systemctl start nginx
systemctl enable nginx

## 確認
curl http://localhost

<出力結果>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Firewall設定

## 80番ポート許可
firewall-cmd --add-port=80/tcp --permanent

## リロード
firewall-cmd --reload

デフォルト公開ディレクトリ

デフォルトの公開ディレクトリは /usr/share/nginx/html となってます。