Nginx サブディレクトリの設定をメモ。
Nginx サブディレクトリの設定
通常「https://localhost/」の際に「/var/www/html」のファイルを見るように設定してるが「https://localhost/test/」の時だけ「/var/www/test」を見るようにサブディレクトリを設定しています。
僕の実行した環境はPHPでLaradockを使用していますが多分大丈夫なはず。
サンプルの「test」の部分を自分が設定したいサブディレクトリの名前に変更してください。
server {
# ~省略~
location /test/ {
root /var/www/test;
try_files $uri $uri/ /test/index.php$is_args$args;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# ~省略~
}
0 件のコメント :
コメントを投稿