CentOS Nginx

CentOS7 にNginx インストール

CentOS

.NET Core 公開用に Nginx インストールしてみた

前回 Apache で .NET Core を公開したが Nginxでもやってみたいのでその準備

環境

  • VPS WebARENA Indigo 安い!(笑)
  • CPU 2vCPU
  • SSD 40GB
  • メモリ 2GB
  • 月額699円(税込)1時間当たり1.1円(税込)初期料金無料
  • CentOS Linux release 7.7.1908 (Core)

インストールの準備

[nginx-stable]版と[nginx-mainline]版があるが、[nginx-mainline]が推奨されているのでこちらをインストールする。

Nginx のレポジトリファイルを追加

いきなり yum でインストールできない
NginxをインストールするにはNginxのレポジトリファイルを追加する必要がある。
レポジトリファイル群は「etc/yum.repos.d/」にある。

[root@i- yum.repos.d]# pwd
/etc/yum.repos.d

次のページを参考にして /etc/yum.repos.d/nginx.repo を作成する

[root@i- yum.repos.d]# vi nginx.repo
[root@i- yum.repos.d]# cat nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1

Nginx のインストール

[root@i- ~]# yum -y install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp-srv2.kddilabs.jp
* extras: ftp-srv2.kddilabs.jp
* updates: ftp-srv2.kddilabs.jp
nginx | 2.9 kB 00:00:00
nginx/x86_64/primary_db | 166 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.17.8-1.el7.ngx will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================
Package Arch Version Repository Size
=============================================================================================================
Installing:
nginx x86_64 1:1.17.8-1.el7.ngx nginx 770 k

Transaction Summary
=============================================================================================================
Install 1 Package

Total download size: 770 k
Installed size: 2.7 M
Downloading packages:
nginx-1.17.8-1.el7.ngx.x86_64.rpm | 770 kB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:nginx-1.17.8-1.el7.ngx.x86_64 1/1
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
Verifying : 1:nginx-1.17.8-1.el7.ngx.x86_64 1/1

Installed:
nginx.x86_64 1:1.17.8-1.el7.ngx

Complete!

Nginx の起動

[root@i- ~]# systemctl start nginx
[root@i- ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2020-01-28 14:32:24 UTC; 11s ago
Docs: http://nginx.org/en/docs/
Process: 7422 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 7423 (nginx)
CGroup: /system.slice/nginx.service
tq7423 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
mq7424 nginx: worker process

Jan 28 14:32:24 i- systemd[1]: Starting nginx - high performance web server...
Jan 28 14:32:24 i- systemd[1]: Started nginx - high performance web server.

自動起動の設定

[root@i- ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

自動起動の設定がなされているか 確認

[root@i- ~]# systemctl is-enabled nginx
enabled

http://NginxのIP/ でnginxの画面が出た。

感想

何もせずに yum でインストールできるようにしていて欲しい。

コメント