nginx虚拟主机的配置
server {
listen 80;
server_name 127.0.0.1;
access_log off;
root /var/www/html/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
##$uri代表请求的文件或文件夹。$args这个变量等于请求行中的参数。
}
location ~ .*\.(php|php5)?$ {
try_files $uri =404; #不懂为什么
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #不懂为什么
#$document_root当前请求在root指令中指定的值.
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
root /data/nginx/cache;
expires 15d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
原文:http://www.cnblogs.com/tangshengwei/p/4978345.html