首先配置好运行环境:

windows下配置nginx+php环境

其次修改nginx配置文件:

server {
        listen       80;
        server_name  localhost;
	location ~ ^/bbs/.+\.php$ {
	   alias		E:/xuetang/cn/bbs;
	   rewrite		/bbs/(.*\.php?) /$1 break;
	   fastcgi_index	index.php;
	   fastcgi_pass		127.0.0.1:9000;
	   fastcgi_param	SCRIPT_FILENAME E:/xuetang/cn/bbs$fastcgi_script_name;
	   include		fastcgi_params;
	}
	location ~ ^/bbs($|/.*) {
	   alias		E:/xuetang/cn/bbs/$1;
	   index		index.php index.html index.htm;
	}

        location / {
            root   E:/xuetang/cn/www;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           E:/xuetang/cn/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

注意虚拟目录配置要在根目录上面。。

1,471 total views, 1 views today

发表评论

电子邮件地址不会被公开。 必填项已用*标注