CentOS 7 + Nginx + rep2 その3
Distributionのレポジトリだと、古いNginxのPkgしかないので
Nginexのレポジトリを登録して、そこから導入する
標準のレポジトリだと、現時点では 1.12.2のStableパッケージだけど
Nginxのサイトによると基本は Mainlineのパッケージ(1.13.12)使用を推奨しているので
Nginxのレポジトリを登録してそちらからインストールするように設定する
Nginxのサイトに従って
-> https://nginx.org/en/linux_packages.html#mainline
# cat > /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=0 enabled=1 <ここで Ctrl+D で出力終了> # chmod 644 nginx.repo # # yum info nginx.x86_64 Available Packages Name : nginx Arch : x86_64 Epoch : 1 Version : 1.13.12 Release : 1.el7_4.ngx Size : 750 k Repo : nginx/x86_64 Summary : High performance web server URL : http://nginx.org/ License : 2-clause BSD-like license Description : nginx [engine x] is an HTTP and reverse proxy server, as well as : a mail proxy server.
無事最新のパッケージを引っ張ってこれるようになったのでインストール
# yum install nginx
サービス登録を実施して、起動
# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. # systemctl start nginx
http://
Nginxのログローテートを設定する
/etc/logrotate.d/nginx がパッケージのインストール時に導入されるのでこれを修正
# cat /etc/logrotate.d/nginx /var/log/nginx/*.log { daily missingok rotate 52 compress delaycompress notifempty create 640 nginx adm sharedscripts postrotate if [ -f /var/run/nginx.pid ]; then kill -USR1 `cat /var/run/nginx.pid` fi endscript } # 上記を修正して、毎日実行から毎週に、過去ログは4week(一ヶ月分)保持するように変更した # cat /etc/logrotate.d/nginx /var/log/nginx/*.log { weekly missingok rotate 4 compress delaycompress notifempty create 640 nginx adm sharedscripts postrotate if [ -f /var/run/nginx.pid ]; then kill -USR1 `cat /var/run/nginx.pid` fi endscript } #