nginx的虚拟站点

server {

    # 服务端口
    listen  80;

    # 指定ip或域名 多个域名之间用空格分开
    server_name  www.ktvll.com;

    # 默认首页
    index index.html index.htm index.php;

    # 网站根目录
    root /alidata/www/default;

    # 访问日志
    access_log  /alidata/log/nginx/access/default.log;

    # 是否允许列出目录
    autoindex    off;

    # 404页面
    error_page 404 = 404.html;

    # 各种错误页面
    error_page 500 502 503 504 = 50x.html;

    # 错误页面如果小于512k则会在IE下被替换成IE摩恩的错误页面

    #  location 语法
    #  /   通用匹配,任何请求都会匹配到
    #  =   开头表示精确匹配
    #  ~   开头表示区分大小写的正则匹配
    #  ~*  开头表示不区分大小写的正则匹配
    #  !~ 和 !~* 分别为区分大小写不匹配及不区分大小写不匹配 的正则
    #  多个location配置匹配顺序为: 从精准到模糊  从=  到/
    #  区分大小写的匹配以 "任意多少个字符" . php或php5的请求
    location ~ .*\.(php|php5)?$
    {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }

    #  区分大小写的匹配以:
    #  "任意多少个字符" . gif|jpg|jpeg|png|bmp|swf结尾的请求
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
            expires 30d;
    }

    #  同上
    location ~ .*\.(js|css)?$
    {
            expires 1h;
    }

    #  expires 为页面缓存时间

}

  

猜你喜欢

转载自www.cnblogs.com/xin-jun/p/9081471.html
今日推荐