| 
 进入conf文件夹,新建vhost文件夹; 将内部的server配置段提取单独放在一个文件里,存到了conf/vhost下,以方便配置多个虚拟主机。 并在nginx.conf里http配置段内添加了一行 include vhost/*.conf;用来读取vhost下的虚拟主机配置。  | http { 
    include       mime.types; 
    default_type  application/octet-stream; 
    sendfile        on; 
    keepalive_timeout  65; 
    include vhost/*.conf;  #新增 
} 
 
 |  
  
配置主机: 进入vhost文件,新建一个mall.conf(你自己想取的名字)文件。 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
 | server { 
        listen       80; 
        server_name  mall.me; #可添加多个,多个之间“空格”分开 
        #autoindex on;#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件 
        location / { 
            root   F:/wnmp/wwwroot/mall; 
            index  index.html index.htm index.php; 
            #此处是伪静态配置 
            if (!-e $request_filename) { 
                rewrite  ^(.*)$  /index.php/?/$1  last;  
                break; 
            }  
        } 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   F:/wnmp/wwwroot; 
        } 
        location ~ \.php$ { 
            root           F:/wnmp/wwwroot/mall; 
            fastcgi_pass   127.0.0.1:9000; 
            fastcgi_index  index.php; 
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
            include        fastcgi_params; 
        } 
    } 
 
 |  
 然后重启你的Nginx服务器。  
 |