Home  >  Article  >  Backend Development  >  Using IIS7 Express to run php_PHP tutorial using FastCgi on Windows 2003

Using IIS7 Express to run php_PHP tutorial using FastCgi on Windows 2003

WBOY
WBOYOriginal
2016-07-20 11:14:00906browse

Let me talk about the background first. Because I rented a VPS to manage the code, documents and run some service programs for my own use. In order to be cheap and stable, I considered renting a windows 2003 vps. The total memory is only 1G. Very stretched.

In terms of Web services, PHP and ASP.NET need to be run on the same server with 2003 installed. After PHP is installed on IIS6, the Rewrite component is installed, and WordPress can run more normally, but later due to the rewrite component It's expired. I went online to find various versions to install, but it still didn't work. It always said it was expired.

So I had to consider using a reverse proxy made with nginx, and switched the dynamic analysis to IIS6 and Apache, but the overall memory usage seemed a bit large, so I disabled Apache and switched to nginx plus PHP-cgi.exe. When I ran wordpress, I found that the access speed seemed to have improved a bit, but the php process automatically exited at every turn, so I wrote a daemon process to manage php-cgi.exe. Later, nginx became abnormal again and had minor problems from time to time. However, php-cgi used the daemon process to only start one process, which often caused problems. If a lot of them were started, plus the memory occupied by the daemon process and php-cgi, It is better to just convert nginx to apache.

In short, it is definitely not easy to run PHP well and save memory under Windows.

Then considering that IIS7.5 Express can run on WIN2003, it not only supports php in the fastcgi method, but also comes with its own Rewrite component. You only need to simply change the rule rules of web.config.

So after Baidu downloaded IIS7.5 Express and installed it, you also need to configure applicationHost.config. First, you have to find where this file is. If it can be found in the IIS7Express directory in "My Documents", that's it. , otherwise it should be in the installation directory of IIS7 Express.

1. First modify: defaultDocument section, add 8c7e1f8c2d6f5d0c1fde1269ab67c831

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

2. Find the fastcgi section.

<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 name="PHPRC" value="C:Program Files (x86)iis expressPHPv5.4" />
                </environmentVariables>
            </application>
</fastCgi>

3. Find handles and join

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

One thing to note in particular is that it is best to add this sentence at the front, that is, the first sentence under e7830b45cc30cfd2772e483980915477, to avoid being processed by other Handles first.

In the above configuration, replace the part of C:phpphp-cgi.exe with the location of php-cgi.exe in your own php folder.

4. Under the 021e4353285e16f5ecec0a77e545d012 configuration section, directly modify the site information, or directly use appcmd.exe add site to add the site.

5. Find the installation folder such as wordpress, create a web.config file, and add Gzip compression rules under the configuration section.

<system.webServer>
   <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

6. Also in web.config, the complete web.config file content of WordPress rewrite is as follows:


  
    
      
        
          
            
              
              
            
          
        
      
    
  
<system.webServer>
   <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

This is completely configured, then find IISExpress.exe in the IIS7 Express directory, double-click to run it, or use the command line to specify which site to load.

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

After visiting it, you will find that the access speed is much faster than using apache under windows, and there is one less nginx to run, and the overall memory usage is much less.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440333.htmlTechArticleLet me talk about the background first, because it is a rented VPS to manage code, documents and run some services that I use. Program, in order to be cheap and stable, I considered renting a Windows 2003 vps. The total memory...
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