CentOS9 nginxをインストールする手順
CentOS9に、webサーバーであるnginxをインストールする手順を記述してます。
環境
- OS CentOS Stream release 9
nginxインストール
先に、アップデートしておきます。
$ sudo dnf update
インストールします。
$ sudo dnf -y install nginx
バージョンを確認します。
$ nginx -version
nginx version: nginx/1.20.1
nginx起動
nginxを起動します。
$ sudo systemctl start nginx
自動起動も設定する場合は、以下となります。
$ sudo systemctl enable --now nginx
ステータスは、以下で確認できます。
$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/nginx.service.d
└─php-fpm.conf
Active: active (running) since Sat 2022-09-10 02:43:29 EDT; 2s ago
Process: 1646900 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1646902 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1646903 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 1646904 (nginx)
Tasks: 2 (limit: 21920)
Memory: 2.1M
CPU: 32ms
CGroup: /system.slice/nginx.service
├─1646904 "nginx: master process /usr/sbin/nginx"
└─1646905 "nginx: worker process"
9月 10 02:43:29 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
9月 10 02:43:29 localhost.localdomain nginx[1646902]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
9月 10 02:43:29 localhost.localdomain nginx[1646902]: nginx: configuration file /etc/nginx/nginx.conf test is successful
9月 10 02:43:29 localhost.localdomain systemd[1]: Started The nginx HTTP and reverse proxy server.
firewallを設定していれば、許可しておきます。
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
$ sudo firewall-cmd --reload
ブラウザから http://プライベートIP or サーバーアドレス にアクセスすると、nginxが起動していることが確認できます。
設定ファイル
設定ファイルは、以下の場所にあります。
/etc/nginx/nginx.conf
ドキュメントルート
デフォルトのドキュメントルートは、以下のパスとなります。
/usr/share/nginx/html
-
前の記事
javascript Mapのサイズを取得する 2022.09.11
-
次の記事
Rocky Linux9 「エラー: 不明な repo : ‘epel’」が発生した場合 2022.09.11
コメントを書く