0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS stream8でNginxをインストールする

Last updated at Posted at 2022-06-28

はじめに

NginxをCentOS stream8にインストールする機会があったので参考になればと記事にしました。

step1 Nginxをインストールするためにリポジトリを作成します

# vi /etc/yum.repos.d/nginx.repo を入力し、nginx.repoファイルを作成し、リポジトリ 1の編集を行います。
下記の内容をすべて記述します。コピペおk

[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

[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

module_hotfixes=true

コピペして貼り付けできたら大丈夫です:v:

step2 nginxをインストールします

# dnf install nginx コマンドを入力する。
※今回はdnfコマンドを使用しています。
image.png
こんな感じでインストールが始まります。
確認をされるので全てyesでおk

step3 Nginxのバージョンを確認する

Nginxのバージョンを確認します。
# nginx -v を打ち、Nginxのバージョンを確認しましょう。
記事時点での実行時のバージョンは、nginx version: nginx/1.22.0です。
image.png

step4 Nginxを自動起動2にしよう♪

# systemctl enable nginx 

上記のコマンドを入力し、自動起動にします。
image.png
Created symlink /systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
上記の文字列が出れば大丈夫です。

step5 Nginxを起動してみよう!!

# systemctl start nginx

を入力します。

次に、Nginxが起動できてるか確認します

# systemctl status nginx

を入力します。
image.png

上記のように、Activeになっていたら終了です。

Nginxにアクセスしてみよう

Nginxを起動したら、サーバのIPアドレスをブラウザに入力してアクセスしてみましょう。下のような画面が表示されていれば、アクセスは成功。

image.png

  1. リポジトリ
    Linuxが必要なアプリケーションを見つけ出せるようにインターネット上のどこのサーバーにアプリケーションが格納されているかを記載したファイル

  2. 自動起動
    サーバー起動、再起動時に自動でスタートを行ってくれるようにするため

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?