本記事の環境
NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"
yumリポジトリの追加
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 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
yum info nginx
Nginxのインストール
yumを利用してNginxをインストール
yum install nginx
ファイヤーウォールの設定
**ファイヤーウォールが有効な場合は80番ポートを開放する
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --reload
Nginxの起動設定
Nginxの自動起動を有効にする
systemctl enable nginx
Nginxの起動と停止
Nginxの起動
systemctl start nginx
Nginxの停止
systemctl stop nginx
Nginxの再起動
systemctl restart nginx
Nginxの設定
Nginxの設定ファイル
/etc/nginx/nginx.conf
Nginxのログディレクトリ
/var/log/nginx/