之前我说道在一个项目(asp+PHP混编的,正在升级到纯PHP)服务器遇见一个奇葩的问题,一直没有解决,(http://spooking.cn/p/c86c9d8345fc),我又想是不是IIS的FastCGI模块和PHP搭配不好?因为网上有很多人遇到IIS+PHP超级慢,但都没有找到办法,都建议用apache,我的服务器已经禁用IPv6,排除localhost的这种情况,也只能这样想了。
apache我不熟悉,在测试机上搭了宝塔windows版本,来运行php,asp用nginx反向到IIS,看看是不是IIS的FastCGI问题,主要是nginx的配置,这个设好了就可以跑起来,测试的问题后面再说。
php部分配置
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass 127.0.0.1:4556;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:4556;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
4556端口是宝塔php共生模式php5.6版本的端口,每个环境不同切不可直接复制。
Asp反向部分配置
#asp(aspx)转发给iis
location ~* \.(asp|aspx|asa)$ {
index index.asp index.php index.html index.htm index.aspx default.php default.html default.htm default.asp default.aspx ;
proxy_pass http://127.0.0.1:9009;
#asp可以通过 X-Real-IP拿到用户的真实IP
proxy_set_header X-Real-IP $remote_addr;
}
9009端口是我设置的IIS站点的访问端口,根据实际情况修改。
伪静态部分配置
location / {
try_files $uri @rewrite;
}
location @rewrite {
set $static 0;
if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
set $static 1;
}
if ($static = 0) {
rewrite ^/u7/(.*)$ /UA7.php?s=/$1;
}
}
这样站点就搭好了,nginx在前,iis在后。
希望测试的结果能给我答案……
网友评论