配置文件里涉及相对目录配置时,都是都是相对于/etc/nginx/

nginx 默认配置

/etc/nginx/nginx.conf

  1. user nginx;
  2. worker_processes 1;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. #tcp_nopush on;
  17. keepalive_timeout 65;
  18. #gzip on;
  19. include /etc/nginx/conf.d/*.conf;
  20. }

/etc/nginx/conf.d/default.conf

  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name localhost;
  5. #charset koi8-r;
  6. #access_log /var/log/nginx/host.access.log main;
  7. location / {
  8. root /usr/share/nginx/html;
  9. index index.html index.htm;
  10. }
  11. #error_page 404 /404.html;
  12. # redirect server error pages to the static page /50x.html
  13. #
  14. error_page 500 502 503 504 /50x.html;
  15. location = /50x.html {
  16. root /usr/share/nginx/html;
  17. }
  18. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  19. #
  20. #location ~ \.php$ {
  21. # proxy_pass http://127.0.0.1;
  22. #}
  23. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  24. #
  25. #location ~ \.php$ {
  26. # root html;
  27. # fastcgi_pass 127.0.0.1:9000;
  28. # fastcgi_index index.php;
  29. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  30. # include fastcgi_params;
  31. #}
  32. # deny access to .htaccess files, if Apache's document root
  33. # concurs with nginx's one
  34. #
  35. #location ~ /\.ht {
  36. # deny all;
  37. #}
  38. }

参考

在线配置生成工具