0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ubuntuでnginx hello world

Last updated at Posted at 2023-05-08

nginx(エンジンエックス)とは

  • Webサーバの一つ

nginx インストール

  • ubuntuから下記コマンド実行
sudo apt update
sudo apt install nginx
  • 確認
nginx -v

nginx 起動

  • ubuntuから下記コマンド実行
sudo nginx

nginxの環境について

  • デフォルトのrootフォルダは/var/www/html
  • /var/www/html に移動
cd /var/www/html
  • ファイルを表示してみる
user01@DESKTOP-5FA6FSN:/var/www/html$ ls
index.nginx-debian.html
  • http://localhost で表示されていた「Welcome ~」は、
    index.nginx-debian.html が表示されていた

hello world

  • /var/www/html/hello.html を作成
sudo vi hello.html
  • hello.htmlに以下のように記述し保存
hello world

nginxの設定ファイルを見てみよう

cd /etc/nginx
view nginx.conf

※linuxの設定ファイルはだいたい/etcにある

なぜ/var/www/htmlにあるファイルを参照するのか

  • viewコマンドで参照すると下記のような設定がある
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

includeで、さらに他のファイルを読み込んでいる

  • includeされている/etc/nginx/sites-enabled/defaultを参照してみる
view sites-enabled/default
  • defaultに
root /var/www/html;

の定義があり、ここで設定されたディレクトリにあるファイルを参照できる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?