設定ファイルの作成・修正
設定ファイルの作成・修正
# cd /etc/nginx/conf.d コンフィグファイルのあるディレクトリへ移動 # cp -p default.conf hogehoge.conf 新たにバーチャルホストに設定するドメインのコンフィグファイルを「default.conf」をコピーして作成 #vi hogehoge.conf server { ←の下 - server_name localhost; + server_name hogehoge.com; location / { ←の下 - root /usr/share/nginx/html; + root /usr/share/nginx/hogehoge; - index index.html index.htm; + index index.html index.php; location ~ \.php$ { ←の下 - root /usr/share/nginx/html; + root /usr/share/nginx/hogehoge;
バーチャルホストのドキュメントルート用のディレクトリ作成
# cd /usr/share/nginx # mkdir hogehoge
テストページの設置
#vi /usr/share/nginx/hogehoge/idnex.html
<html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">Test Page</div> </body> </html>
設定の反映
書式のエラーチェック
#nginx -t
「nginx」の再起動
#systemctl restart nginx
「http://hogehoge.com」にブラウザでアクセスして表示確認する。