nginx 配置虚拟主机(支持php)

配置步骤:

1、在nginx安装目录下,找到nginx.conf所在文件夹,新建vhost文件夹

2、在nginx.conf http{} 末端加入 include vhost/*.conf;

3、进入第一步创建的文件中,新建所需的配置文件  kt.conf

4、编辑 kt.conf 加入以下内容

server {
    listen 80;
    server_name www.kt.hd;
    root C:/www/kt/;
    index index.php index.html index.htm;


    location / {
       try_files $uri $uri/ /index.php$is_args$args; #去除框架中index.php
    }

    location ~ \.php$ {
        
    fastcgi_pass   127.0.0.1:9000;
    #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }


}

5、重启nginx

posted @ 2016-12-30 12:01  黄加菜  阅读(731)  评论(0编辑  收藏  举报