1
2

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 8にNginx mainline最新版をインストール(公式repository)

Last updated at Posted at 2019-09-26

はじめに

公式repositoryを利用してCentOS8にNginx mainline最新版をインストール
親記事:Nginxの各種インストール方法とEOLまとめ
参考:[nginx: Linux packages] (https://nginx.org/en/linux_packages.html#RHEL-CentOS)

サポート

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

note

  • yum-utilsも入れたいたほうが良いかも(本LOGでは入れてない)
sudo yum install yum-utils
  • パッケージ名が被っているので無理やり入れてみたけど、これで正しいのかわからない
    • この導入方法のあとにyum updateしてもOS標準バージョンで上書きされることは無い模様
    • 綺麗なインストール方法が案内されるまで様子見が良さそう

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 8.0.1905 (Core)

# yum --disablerepo=AppStream install -y nginx
... 略

nginx起動/停止

# systemctl start nginx
# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           mqphp-fpm.conf
   Active: active (running) since Thu 2019-09-26 07:38:43 EDT; 9s ago
     Docs: http://nginx.org/en/docs/
  Process: 31408 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 31409 (nginx)
    Tasks: 2 (limit: 11109)
   Memory: 2.5M
   CGroup: /system.slice/nginx.service
           tq31409 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           mq31410 nginx: worker process

Sep 26 07:38:43 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Sep 26 07:38:43 localhost.localdomain systemd[1]: Started nginx - high performance web server.
# systemctl stop nginx
# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           mqphp-fpm.conf
   Active: inactive (dead)
     Docs: http://nginx.org/en/docs/

Sep 26 06:36:54 localhost.localdomain systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Sep 26 06:36:54 localhost.localdomain systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Sep 26 07:25:51 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Sep 26 07:25:51 localhost.localdomain systemd[1]: Started nginx - high performance web server.
Sep 26 07:26:24 localhost.localdomain systemd[1]: Stopping nginx - high performance web server...
Sep 26 07:26:24 localhost.localdomain systemd[1]: Stopped nginx - high performance web server.
Sep 26 07:38:43 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Sep 26 07:38:43 localhost.localdomain systemd[1]: Started nginx - high performance web server.
Sep 26 07:39:09 localhost.localdomain systemd[1]: Stopping nginx - high performance web server...
Sep 26 07:39:09 localhost.localdomain systemd[1]: Stopped nginx - high performance web server.

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

# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /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 /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
Last metadata expiration check: 0:01:50 ago on Thu 26 Sep 2019 07:38:28 AM EDT.
Installed Packages
Name         : nginx
Epoch        : 1
Version      : 1.17.4
Release      : 1.el8.ngx
Arch         : x86_64
Size         : 2.9 M
Source       : nginx-1.17.4-1.el8.ngx.src.rpm
Repo         : @System
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.
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?