nginx每个站点创建独立的配置文件

环境

  • nginx1.5.2

配置

server_names_hash_bucket_size 64; 
include E:/wnmp/nginx/vhosts/*.conf;
  •  在ngxin文件夹内创建“vhosts”文件夹
  • 例如:域名1 example1.com 放在 E:/wnmp/www/example1
  • 在vhosts文件夹内创建:example1.com.conf文件,内容如下:
  • server {
            listen  80;
            server_name  example1.koolbao.com;
            root   E:/wnmp/www/example1;
            #access_log  /www/access_ example1.log  main;
    
            location / {
                index  index.php index.html index.htm;
                #autoindex on;#如果文件不存在列出目录结构;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
    
            location ~ \.php {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param   PATH_INFO $fastcgi_path_info;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    				
    				 
            if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1 last;
                break;
        		}
    				
            location ~ /\.ht {
                deny  all;
            }
    }
     好了,见证奇迹的时刻到了。

你可能感兴趣的:(nginx)