nginx 和 IIS 搭建asp+php站点如何配置

之前我说道在一个项目(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在后。
希望测试的结果能给我答案……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值