nginx虚拟机搭建

来源:互联网 发布:电脑在线看电视软件 编辑:程序博客网 时间:2024/05/16 11:54
expires 是web服务器响应消息头字段,在响应http请求时告诉浏览器在过期时间前可以直接获取缓存的数据,而不需要请求
一、
server {
#监听端口
listen  80;
#域名
server_name yys.eloancn.com;
#加载内容
location / {
            root /usr/local/nginx/html/bbs;
            index index.php index.jsp index.htm index.html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/bbs$fastcgi_script_name;
            include        fastcgi_params;
        }
#加载一些格式
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            root /usr/local/nginx/html/bbs;
            expires 30d;
        }
#加载一些样式
        location ~ .*\.(js|css)?$
        {
            root /usr/local/nginx/html/bbs;
            expires 1h;
        }
   }



二、root写在server下
server {
     listen      80;
     server_name www.example.com;
     root        /data/www ;
     location / {
         index   index.html index.php;
     }
     location ~* \.(gif|jpg|png)$ {
         expires 30d;
     }
     location ~ \.php$ {
             fastcgi_pass  localhost:9000;
             fastcgi_param SCRIPT_FILENAME
             $document_root$fastcgi_script_name;
             include       fastcgi_params;
         }
     }
0 0
原创粉丝点击