search
Homephp教程php手册Windows2003上使用IIS7 Express使用FastCgi运行php

先说一下背景,因为是自己租来的VPS管理代码、文档及跑一些自己用的一些服务程序,为了便宜又稳定就考虑租了台windows2003的vps,内存总共只1G,很捉襟见肘。 在Web服务这一块,同一台装了2003的服务器上,需要跑PHP及ASP.NET,IIS6上安装了PHP后,加装Rewri

     先说一下背景,因为是自己租来的VPS管理代码、文档及跑一些自己用的一些服务程序,为了便宜又稳定就考虑租了台windows2003的vps,内存总共只1G,很捉襟见肘。

     在Web服务这一块,同一台装了2003的服务器上,需要跑PHP及ASP.NET,IIS6上安装了PHP后,加装Rewrite组件,可以较正常的跑wordpress,但后来由于rewrite组件过期了,去网上找了各种版本的安装,仍然无用,总是提示已过期。

     于是只好考虑用用nginx做的反向代理,动态解析转向到IIS6及Apache上,但这样整体内存占用看起来有点大,于是停用了Apache,转而用nginx加PHP-cgi.exe来跑wordpress,发现访问速度似乎提升了一些,但是php进程动不动就自动退出,于是又写个管理php-cgi.exe的守护进程。后来,nginx又不正常了,时不时出点小毛病,而php-cgi用守护进程只启动一个进程,也时常出问题,如果启动一堆的话,加上守护进程与php-cgi所占用的内存,还不如直接nginx转apache算了。

     总之,确定在windows下,想好好跑php,又要节省内存,真的不容易。

     然后考虑到IIS7.5 Express可以在WIN2003上跑,不但能以fastcgi的方式支持php,还自带Rewrite组件,只需简单改改web.config的rule规则就可以了。

     于是百度下载了IIS7.5 Express后,安装,还需要对applicationHost.config进行配置,首先得找到这个文件在哪里,如果能在"我的文档"中IIS7Express目录下找到,那就是它了,否则应该就是在IIS7 Express的安装目录下。

     1、先修改:defaultDocument节,加入

<defaultdocument enabled="true">
            <files>
                <add value="Default.htm"></add>
                <add value="Default.asp"></add>
                <add value="index.htm"></add>
                <add value="index.html"></add>
                <add value="iisstart.htm"></add>
                <add value="default.aspx"></add>
                <add value="index.php"></add>
            </files>
</defaultdocument>

 

     2、找到fastcgi节。

<fastcgi>
            <application fullpath="C:\php\php-cgi.exe" monitorchangesto="php.ini" activitytimeout="600" requesttimeout="600" instancemaxrequests="10000">
                <environmentvariables>
                    <environmentvariable name="PHP_FCGI_MAX_REQUESTS" value="10000"></environmentvariable>
                    <environmentvariable name="PHPRC" value="C:Program Files (x86)iis expressPHPv5.4"></environmentvariable>
                </environmentvariables>
            </application>
</fastcgi>

   3、找到handlles,加入

 <add name="PHP_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptprocessor="C:\PHP\php-cgi.exe" resourcetype="Either"></add>

    尤其要注意的一是,这一句最好加在最前面,也就是在下面的第一句,避免被其它Handle抢先处理了。

    以上配置中,C:\php\php-cgi.exe 的部分替换成自己的php文件夹中的php-cgi.exe的位置。

  4、在配置节下,直接修改站点信息,或直接用appcmd.exe add site来添加站点。

 

  5、找到诸如wordpress的安装文件夹,创建一个web.config文件,在configuration配置节下,添加Gzip压缩规则。

<system.webserver>
   <urlcompression dostaticcompression="true" dodynamiccompression="true"></urlcompression>
</system.webserver>

 6、同样在web.config中,Wordpress的rewrite完整的web.config文件内容如下:


  
    
      
        
          
            
              
              
            
          
        
      
    
  
<system.webserver>
   <urlcompression dostaticcompression="true" dodynamiccompression="true"></urlcompression>
</system.webserver>

 这样就完全配置完毕了,然后在IIS7 Express目录下,找到IISExpress.exe,直接双击运行,或者用命令行来执行指定加载哪个站点. 

iisexpress.exe /site:'站点名称1"
iisexpress.exe /site:'站点名称2"

 访问一下,就会发现访问速度比在windows下使用apache要快得多,而且少跑一个nginx,内存占用整体上也少了很多。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.