Mặc định có liên quan đến prefixtùy chọn của configuretập lệnh khi nginx được biên dịch; đây là một số mẫu lạ từ Debian:
% nginx -V | & tr ' ' "\n" | fgrep -e path -e prefix
--prefix=/etc/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-log-path=/var/log/nginx/access.log
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--lock-path=/var/lock/nginx.lock
--pid-path=/var/run/nginx.pid
Sau đó, giá trị mặc định rootđược thiết lập để các htmlthư mục (theo tài liệu của rootchỉ thị ), mà sẽ xảy ra là trong phạm vi prefix, như có thể được xác nhận bằng cách nhìn vào $document_rootbiến từ một tập tin cấu hình đơn giản:
# printf 'server{listen 4867;return 200 $document_root\\n;}\n' \
>/etc/nginx/conf.d/so.10674867.conf
# nginx -s reload && curl localhost:4867
/etc/nginx/html
Tuy nhiên, các bản phân phối độc ác như Debian dường như sửa đổi nó khá nhiều, để giúp bạn giải trí thêm:
% fgrep -e root -e include /etc/nginx/nginx.conf
include /etc/nginx/mime.types;
#include /etc/nginx/naxsi_core.rules;
#passenger_root /usr;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
% fgrep -e root -e include \
/etc/nginx/conf.d/*.conf /etc/nginx/sites-enabled/*
/etc/nginx/conf.d/so.10674867.conf:server{listen 4867;return 200 $document_root\n;}
/etc/nginx/sites-enabled/default: root /usr/share/nginx/www;
/etc/nginx/sites-enabled/default: # include /etc/nginx/naxsi.rules
/etc/nginx/sites-enabled/default: # root /usr/share/nginx/www;
/etc/nginx/sites-enabled/default: # include fastcgi_params;
/etc/nginx/sites-enabled/default: # deny access to .htaccess files, if Apache's document root
/etc/nginx/sites-enabled/default:# root html;
/etc/nginx/sites-enabled/default:# root html;
Vì vậy, trong trường hợp này của Debian, bạn có thể thấy rằng root cuối cùng đã được đặt thành /usr/share/nginx/www.
Nhưng như bạn đã thấy với cấu hình máy chủ mẫu sẽ phục vụ $document_rootgiá trị của nó qua http, việc định cấu hình nginx đủ đơn giản để bạn có thể viết cấu hình của riêng mình trong một hoặc hai dòng, chỉ định yêu cầu rootđể đáp ứng nhu cầu chính xác của bạn.