1. NGINXのインストール
Ubuntuでのインストール
sudo apt update
sudo apt install nginx
2. NGINXの起動・停止・再起動
NGINXの起動
sudo systemctl start nginx
NGINXの停止
sudo systemctl stop nginx
NGINXの再起動
sudo systemctl restart nginx
NGINXの設定の再読み込み
sudo systemctl reload nginx
NGINXのステータス確認
sudo systemctl status nginx
3. NGINXの設定ファイルの編集
設定ファイルの場所
NGINXのメイン設定ファイルは通常 /etc/nginx/nginx.conf
にあります。
設定ファイルの編集
sudo nano /etc/nginx/nginx.conf
サイト設定ファイルの編集
通常、サイトごとの設定は /etc/nginx/sites-available/
フォルダにあります。例えば、デフォルトのサイト設定を編集する場合:
sudo nano /etc/nginx/sites-available/default
4. NGINXの設定のテスト
設定ファイルの文法チェック
NGINXの設定ファイルを編集した後、文法チェックを行います。
sudo nginx -t
エラーがなければ、以下のようなメッセージが表示されます:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
5. NGINXのログの確認
エラーログの確認
sudo tail -f /var/log/nginx/error.log
アクセスログの確認
sudo tail -f /var/log/nginx/access.log
6. その他の便利なコマンド
NGINXのバージョン確認
nginx -v
NGINXの詳細バージョン情報確認
nginx -V
NGINXのヘルプ表示
nginx -h