前の記事
構築編
環境確認編
OCIでのyumアップデート編
nginx
1.nginxのインストール
1.1.nginxをインストール
yum installでのインストール
yum installインストール
[opc@test-server ~]$ sudo yum install nginx -y
Last metadata expiration check: 2:12:23 ago on XXX 99 Xxx 2099 99:99:99 AM GMT.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nginx x86_64 2:1.20.1-24.0.1.el9_7.3 ol9_appstream 50 k
Installing dependencies:
nginx-core x86_64 2:1.20.1-24.0.1.el9_7.3 ol9_appstream 589 k
nginx-filesystem noarch 2:1.20.1-24.0.1.el9_7.3 ol9_appstream 10 k
oracle-logos-httpd noarch 90.4-1.0.1.el9 ol9_baseos_latest 37 k
Transaction Summary
================================================================================
Install 4 Packages
Total download size: 686 k
Installed size: 1.8 M
Downloading Packages:
(1/4): nginx-1.20.1-24.0.1.el9_7.3.x86_64.rpm 192 kB/s | 50 kB 00:00
(2/4): nginx-core-1.20.1-24.0.1.el9_7.3.x86_64. 1.8 MB/s | 589 kB 00:00
(3/4): nginx-filesystem-1.20.1-24.0.1.el9_7.3.n 93 kB/s | 10 kB 00:00
(4/4): oracle-logos-httpd-90.4-1.0.1.el9.noarch 71 kB/s | 37 kB 00:00
--------------------------------------------------------------------------------
Total 1.2 MB/s | 686 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-filesystem-2:1.20.1-24.0.1.el9_7.3.noarch 1/4
Installing : nginx-filesystem-2:1.20.1-24.0.1.el9_7.3.noarch 1/4
Installing : nginx-core-2:1.20.1-24.0.1.el9_7.3.x86_64 2/4
Installing : oracle-logos-httpd-90.4-1.0.1.el9.noarch 3/4
Installing : nginx-2:1.20.1-24.0.1.el9_7.3.x86_64 4/4
Running scriptlet: nginx-2:1.20.1-24.0.1.el9_7.3.x86_64 4/4
Verifying : oracle-logos-httpd-90.4-1.0.1.el9.noarch 1/4
Verifying : nginx-2:1.20.1-24.0.1.el9_7.3.x86_64 2/4
Verifying : nginx-core-2:1.20.1-24.0.1.el9_7.3.x86_64 3/4
Verifying : nginx-filesystem-2:1.20.1-24.0.1.el9_7.3.noarch 4/4
Installed:
nginx-2:1.20.1-24.0.1.el9_7.3.x86_64
nginx-core-2:1.20.1-24.0.1.el9_7.3.x86_64
nginx-filesystem-2:1.20.1-24.0.1.el9_7.3.noarch
oracle-logos-httpd-90.4-1.0.1.el9.noarch
1.2.現在の稼働状態を確認
systemctlコマンドで確認
インストールモジュールをバージョン表示で確認
[opc@test-server ~]$ sudo nginx -V
nginx version: nginx/1.20.1
built by gcc 11.5.0 20240719 (Red Hat 11.5.0-11.0.2) (GCC)
built with OpenSSL 3.5.1 1 Jul 2025
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,-E'
現在の稼働状態を確認
[opc@test-server ~]$ sudo systemctl status nginx
○ nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: d>
Active: inactive (dead)
インストール時の自動起動はなし。
サービス自動起動設定の確認
[opc@test-server ~]$ sudo systemctl is-enabled nginx
disabled
disabled:無効なので、自動起動しない
2.起動設定
2.1.systemctlでの自動起動設定
systemctlでの自動起動を有効化
systemctlでの自動起動登録
[opc@test-server ~]$ sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
サービス自動起動設定の確認
[opc@test-server ~]$ sudo systemctl is-enabled nginx
enabled
2.2.systemctlでの手動起動
systemctlでnginxを起動
サービス起動
[opc@test-server ~]$ sudo systemctl start nginx
[opc@test-server ~]$
現在の稼働状態を確認
[opc@test-server ~]$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: di>
Active: active (running) since Sat 2026-05-30 03:00:21 GMT; 40s ago
Process: 295362 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, st>
Process: 295363 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCC>
Process: 295364 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 295365 (nginx)
Tasks: 3 (limit: 5126)
Memory: 2.9M (peak: 3.2M)
CPU: 50ms
CGroup: /system.slice/nginx.service
tq295365 "nginx: master process /usr/sbin/nginx"
tq295366 "nginx: worker process"
mq295367 "nginx: worker process"
May 30 03:00:21 test-server systemd[1]: Starting The nginx HTTP and reverse pro>
May 30 03:00:21 test-server nginx[295363]: nginx: the configuration file /etc/n>
May 30 03:00:21 test-server nginx[295363]: nginx: configuration file /etc/nginx>
May 30 03:00:21 test-server systemd[1]: Started The nginx HTTP and reverse prox>
システム再起動して確認
[opc@test-server ~]$ sudo reboot
システム再起動後に確認
[opc@test-server ~]$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: di>
Active: active (running) since Sat 2026-05-30 03:07:56 GMT; 4min 15s ago
Process: 2260 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, stat>
Process: 2280 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCES>
Process: 2318 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 2347 (nginx)
Tasks: 3 (limit: 2264)
Memory: 2.2M (peak: 4.4M)
CPU: 63ms
CGroup: /system.slice/nginx.service
tq2347 "nginx: master process /usr/sbin/nginx"
tq2348 "nginx: worker process"
mq2349 "nginx: worker process"
3.アクセス制限の設定
初期状態ではアクセス制限がかかっているため解除する
初期アクセス制限設定(firewalld)の確認
3.1.firewallアクセス可能設定の追加
firewallの設定変更
ポートの確認の確認
[opc@test-server ~]$ sudo firewall-cmd --list-ports
何もないので、設定なし
httpポート:80とhttpsポート:443の追加
[opc@test-server ~]$ sudo firewall-cmd --permanent --add-port=80/tcp
success
[opc@test-server ~]$ sudo firewall-cmd --permanent --add-port=443/tcp
success
--permanentをつけると、永続的に設定が追加されます。
ポート追加しただけでは設定が反映されないので、firewalldを再起動
[opc@test-server ~]$ sudo firewall-cmd --reload
success
[opc@test-server ~]$ sudo firewall-cmd --list-ports
80/tcp 443/tcp
3.2.curlコマンドで動作確認
curlコマンドで動作確認
curl -I を使いローカル接続状況を確認
[opc@test-server ~]$ curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Xxx, 99 XXX 2099 99:99:99 GMT
Content-Type: text/html
Content-Length: 4395
Last-Modified: Tue, 13 XXX 2099 99:99:99 GMT
Connection: keep-alive
ETag: "6823aae4-112b"
Accept-Ranges: bytes
-I:コンテンツ詳細を省略した出力
curl -I を使いグローバル接続状況を確認
[opc@test-server ~]$ curl -I http://(自身のグローバルIPアドレス)
(応答なし)
応答なしの時は、ターミナル[CTRL]+[C]で抜ける
curl -I を使い内部から外部サーバーに対するアクセス可能性を確認
[opc@test-server ~]$ curl -I https://www.google.co.jp
HTTP/1.1 200 OK
Content-Type: text/html; charset=Shift_JIS
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-NAW0sa8ar0w2zVFfiy9mHg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
(省略)
内部から外部サーバーへのアクセスができるので、内部から外部への設定上は問題なし。
3.3.OCIプラットフォーム側の設定確認&変更
pingが通らない→通すときのメモ
環境確認編
OCIのプラットフォーム側の設定確認と変更

HTTP(80ポート)、HTTPS(443ポート)のどちらもないので追加する
↓
リスト上にある[イングレス・ルールの追加]ボタンをクリック
↓
以下の通り入力

| 項目 | 記載内容 | 備考 |
|---|---|---|
| ソースCIDR | 0.0.0.0/0 | すべてのIPアドレス |
| IPプロトコル | TCP | HTTP通信のプロトコル TCPを指定 |
| ソース・ポート範囲 | All | 通信発生元のポート Allを指定 |
| 宛先・ポート範囲 | 80 | HTTP通信のポート 80を指定 |
| 説明 | HTTP | HTTP通信がわかるようなコメント |
入力が終わったら、入力リスト下部にある[別のイングレス・ルール]をクリック
↓
以下の通り入力

| 項目 | 記載内容 | 備考 |
|---|---|---|
| ソースCIDR | 0.0.0.0/0 | すべてのIPアドレス |
| IPプロトコル | TCP | HTTPS通信のプロトコル TCPを指定 |
| ソース・ポート範囲 | All | 通信発生元のポート Allを指定 |
| 宛先・ポート範囲 | 443 | HTTPS通信のポート 443を指定 |
| 説明 | HTTPS | HTTPS通信がわかるようなコメント |
入力が終わったら、画面の右下にある[イングレス・ルールの追加]をクリック
↓
前のリスト一覧画面に戻って

追加されていることを確認する。
3.4.curlコマンドで動作確認
curlコマンドで動作確認
curl -I を使いローカル接続状況を確認
[opc@test-server ~]$ curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Xxx, 99 XXX 2099 99:99:99 GMT
Content-Type: text/html
Content-Length: 4395
Last-Modified: Tue, 13 XXX 2099 99:99:99 GMT
Connection: keep-alive
ETag: "6823aae4-112b"
Accept-Ranges: bytes
-I:コンテンツ詳細を省略した出力
curl -I を使いグローバル接続状況を確認
[opc@test-server ~]$ curl -I http://(自身のグローバルIPアドレス)
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Xxx, 99 XXX 2099 99:99:99 GMT
Content-Type: text/html
Content-Length: 4395
Last-Modified: Tue, 13 XXX 2099 99:99:99 GMT
Connection: keep-alive
ETag: "6823aae4-112b"
Accept-Ranges: bytes
3.5.外部からアクセス
最後に
記事の内容はCC BY-SA 4.0(著作者の情報とCCライセンス継承はお願いします。商用利用・改変・再配布は問題なし)です。
