服务器技术

 首页 > 服务器技术 > nginx > nginx将泛解析的匹配域名绑定到子目录配置方法

nginx将泛解析的匹配域名绑定到子目录配置方法

分享到:
【字体:
导读:
          这篇文章主要介绍了nginx将泛解析的匹配域名绑定到子目录配置方法,需要的朋友可以参考下...

nginx将泛解析的匹配域名绑定到子目录的配置方法如下

复制代码 代码如下:
server {
    listen        80;
    server_name   domain.com    *.domain.com;

    if ($host ~* ^([^.]+).([^.]+.[^.]+)$) {
        set $subdomain $1;
        set $domain $2;
    }

    location / {
        root    /home/wwwroot/$domain/$subdomain/;
        index   index.php index.html index.htm;
        #include /home/wwwroot/$domain/$subdomain/.ngx.htaccess;
    }

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   html;
    }

    location ~ .php$ {
        root           /home/wwwroot/$domain/$subdomain/;
        fastcgi_pass   127.0.0.1:9100;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

分享到:
Nginx could not build the server_names...
在给nginx 配置了一个超长的域名后,通过 /usr/local/nginx/sbin/ngnix -t 检查配置文件时出现一下错误:复制代码 代码如下:could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32解决办法是在nginx的配置文件的http段中增加如下配置:复制代码 代码如下:server_names_hash_bucke...
nginx访问日志并删除指定天数前的日志记...
说明: 操作系统:CentOS 站点1:bbs.jb51.net 站点2:sns.jb51.net Nginx安装路径:/usr/local/nginx Nginx配置文件路径:/usr/local/nginx/conf/nginx.conf 站点1配置文件路径:/usr/local/nginx/conf/vhost/bbs.jb51.net.conf 站点2配置文件路径:/usr/local/nginx/conf/vhost/sns.jb51.net.conf 目的: 1、对...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……