OS標準のインストール
dnfコマンドでインストール
まずモジュールの確認
$ dnf module list nginx
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
nginx 1.14 [d] common [d] nginx webserver
nginx 1.16 common [d] nginx webserver
nginx 1.18 [e] common [d] nginx webserver
nginx 1.20 common [d] nginx webserver
nginx 1.22 common [d] nginx webserver
nginx 1.24 common [d] nginx webserver
ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled
一覧から使用するバージョンを切り替える。
nginxのmainlineレポジトリでバージョンを変えたい場合
標準のnginxをリセット
$ sudo dnf module reset nginx
epelをdnfでインストール
$ sudo dnf install epel-release
$ sudo dnf update
mainlineのバージョンを指定してインストール
$ sudo dnf module install nginx:mainline/common
ポートの解放
SELinuxの設定
setenforceコマンドでdisabledにするか
443ポートをssh_port_tに追加する。
詳しくはこちら
firewalldの設定
設定の確認
$ sudo firewall-cmd --list-all
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: cockpit dhcpv6-client
ports:
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
servicesのことろにhttps(必要ならhttpも)を追加する
--add-service=https http
ポート指定なら--add-port=443/tcp
$ sudo fireall-cmd --add-service=https --permanent --zone=public
$ sudo fireall-cmd --add-service=http --permanent --zone=public
--permanentはサービスやOSの再起動しても設定を維持する。
--zone=は設定を変更するインタフェース(に紐づく名称)。NICが複数ある場合は注意
$ sudo firewall-cmd --get-active-zones
public
interfaces: ens3
インタフェース名ens3ではなくゾーン名publicを指定する。
再ロードする。
$ sudo firewall-cmd --reload
success
設定されているか確認
$ sudo firewall-cmd --list-all
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: cockpit dhcpv6-client http https
ports:
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: