免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5856 | 回复: 1
打印 上一主题 下一主题

Nginx的root配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-22 16:36 |只看该作者 |倒序浏览
Nginx的root配置

root

syntax: root path

default: root html

context: http, server, location, if in location

root specifies the document root for the requests. For example, with this configuration

location  /i/ {
        root  /spool/w3;
    }

A request for "/i/top.gif" will return the file "/spool/w3/i/top.gif". You can use variables in the argument.

发现还有种方法
            root   /usr/www/$host;

但还不完善。
我想要 root /usr/www/$1/$2/$3这样的写法。
不晓得其他人有没有这样的例子?

论坛徽章:
0
2 [报告]
发表于 2008-07-22 16:51 |只看该作者

  1. server {
  2.         # Replace this port with the right one for your requirements
  3.         listen       80;  #could also be 1.2.3.4:80

  4.         # Multiple hostnames seperated by spaces.  Replace these as well.
  5.         server_name  star.yourdomain.com *.yourdomain.com www.*.yourdomain.com;
  6.         #Alternately: _ *  
  7.         root /PATH/TO/WEBROOT/$host;
  8.         error_page  404              [url]http://yourdomain.com/errors/404.html[/url];
  9.         access_log  logs/star.yourdomain.com.access.log;
  10.         location / {
  11.             root   /PATH/TO/WEBROOT/$host/;
  12.             index  index.php;
  13.         }

  14.         # serve static files directly
  15.         location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
  16.             access_log        off;
  17.             expires           30d;
  18.         }

  19.         location ~ .php$ {
  20.           # By all means use a different server for the fcgi processes if you need to
  21.           fastcgi_pass   127.0.0.1:YOURFCGIPORTHERE;  
  22.           fastcgi_index  index.php;

  23.           fastcgi_param  SCRIPT_FILENAME  /PATH/TO/WEBROOT/$host/$fastcgi_script_name;
  24.           fastcgi_param  QUERY_STRING     $query_string;
  25.           fastcgi_param  REQUEST_METHOD   $request_method;
  26.           fastcgi_param  CONTENT_TYPE     $content_type;
  27.           fastcgi_param  CONTENT_LENGTH   $content_length;
  28.           fastcgi_intercept_errors on;
  29.         }

  30.         location ~ /\.ht {
  31.             deny  all;
  32.         }
  33.      }
复制代码

官方对于一般用户来说够用了。但目录级别还不可以指定
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP