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 5 years have passed since last update.

CentOS 7にNginx mainline最新版をインストール(公式repository)

Posted at

はじめに

公式repositoryを利用してCentOS7にNginx mainline最新版をインストール
親記事:Nginxの各種インストール方法とEOLまとめ
参考:nginx: Linux packages

サポート

本手法で導入した場合、nginxの開発が停止するまでサポートされると思われる。
特定のバージョンを指定しなければ、mainline最新版が常に提供されると思われる。

LOG

レポジトリ登録

# vi /etc/yum.repos.d/nginx.repo
/etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
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=1
gpgkey=https://nginx.org/keys/nginx_signing.key

インストール

# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

# yum install -y nginx which
... 略

nginx起動/停止

# systemctl start nginx
# systemctl status -l nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-14 14:43:18 UTC; 5s ago
     Docs: http://nginx.org/en/docs/
  Process: 209 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 210 (nginx)
   CGroup: /docker/3958968fa78fc4022e085070a496f6c485f439fd4b9677c28706f5a9dcf50d47/system.slice/nginx.service
           tq210 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           mq211 nginx: worker process
           ? 210 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

Oct 14 14:43:18 3958968fa78f systemd[1]: Starting nginx - high performance web server...
Oct 14 14:43:18 3958968fa78f systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
Oct 14 14:43:18 3958968fa78f systemd[1]: Started nginx - high performance web server.
# systemctl stop nginx
# systemctl status -l nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://nginx.org/en/docs/

Oct 14 14:43:18 3958968fa78f systemd[1]: Starting nginx - high performance web server...
Oct 14 14:43:18 3958968fa78f systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
Oct 14 14:43:18 3958968fa78f systemd[1]: Started nginx - high performance web server.
Oct 14 14:44:44 3958968fa78f systemd[1]: Stopping nginx - high performance web server...
Oct 14 14:44:44 3958968fa78f systemd[1]: Stopped nginx - high performance web server.

nginx自動起動設定/設定解除

# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

# systemctl list-unit-files --type=service |grep nginx
nginx-debug.service                    disabled
nginx.service                          enabled
# systemctl disable nginx
Removed symlink /etc/systemd/system/multi-user.target.wants/nginx.service.

# systemctl list-unit-files --type=service |grep nginx
nginx-debug.service                    disabled
nginx.service                          disabled

各種確認

# which nginx
/usr/sbin/nginx

# nginx -v
nginx version: nginx/1.17.4

# yum info nginx
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Installed Packages
Name        : nginx
Arch        : x86_64
Epoch       : 1
Version     : 1.17.4
Release     : 1.el7.ngx
Size        : 2.7 M
Repo        : installed
From repo   : nginx-mainline
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.
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?