Nginx のインストール
はじめに
このページでは、CentOS 7 に Nginx をインストールする手順について説明します。
本手順に記載のバージョンは、適宜読み替えてください。
1.リポジトリ情報の登録
/etc/yum.repos.d/nginx.repo ファイルを作成(もしくは編集)します。
実行コマンド
# vi /etc/yum.repos.d/nginx.repo編集内容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1Redhat Enterprise Linux 7 の場合は baseurl が次のものになります
http://nginx.org/packages/mainline/rhel/7/$basearch/CentOS, Red Hat Enterprise Linux を使用する場合の注意点
CentOS や Red Hat Enterprise Linux 上に構築する場合、SELinux が有効化されていると通信が通りません。
適宜設定を変更してください。
2.インストール
次のコマンドで Nginx をインストールします。
実行コマンド
# yum install nginx3.サービスの設定
次のコマンドで Nginx サービスの自動起動を設定します。
実行コマンド
# systemctl enable nginx \
&& systemctl is-enabled nginx \
&& systemctl list-unit-files --type=service | grep nginx実行結果
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.enabled
nginx-debug.service disabled
nginx.service enabledNginx のサービスを起動します。
実行コマンド
# systemctl start nginx.service \
&& systemctl status nginx.service