IIS + FastCGI + php5.3 + mysql5.1 + gzip detailed configuration graphic tutorial

Source: Internet
Author: User
Tags configuration php vc9 metabase

Name of the software used in this article and:
Php5.3.2: php-5.3.2-nts-Win32-VC9-x86.zip
Address: http://windows.php.net/downloads/releases/php-5.3.2-nts-Win32-VC9-x86.zip

 

MySQL: mysql-essential-5.1.48-win32.msi
Address: http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.1/mysql-essential-5.1.48-win32.msi

FastCGI: There are two configuration methods.

PhpMyAdmin: Version 3.3.4 is used in this document.

Zend optimizer: The current Zend optimizer does not support php5.3.2. We will reinstall it after the new version is released.

Php5.3 version Selection
Php5.3 for Windows provides four versions: vc9 x86 non thread safe, vc9 x86 thread safe, vc6 x86 non thread safe, and vc6 x86 thread safe, refer to the English version on the left of the PHP official website to see what the differences are between these versions.

I. How to select the vc9 and vc6 versions of php5.3
Vc6 is compiled using the Visual Studio 6 compiler. If your PHP is set up using Apache, select vc6.
Vc9 is compiled using the Visual Studio 2008 compiler. If your PHP is set up using IIS, you can select vc9.

Ii. How to select the thread safe and non-thread safe versions of php5.3
First, it is literally understood that thread safe is thread security, and thread security check is performed during execution, to prevent the new thread from consuming system resources by starting the CGI execution mode. Non-thread safe is non-thread security and does not perform thread security checks during execution.
Let's take a look at two PHP Execution Methods: ISAPI and FastCGI.
The ISAPI is executed in the form of a DLL dynamic library and can be executed after a user request. After processing a user request, the ISAPI does not disappear immediately. Therefore, you need to perform a thread security check, in this way, the program execution efficiency is improved. If you use ISAPI to execute PHP, we recommend that you select the thread safe version;
FastCGI executes operations in a single thread, so it does not need to perform thread security checks. Apart from the thread security check protection, it can improve the execution efficiency, if you use FastCGI to execute PHP, we recommend that you select the non-thread safe version.

We use IIS + FastCGI to configure the server environment, so we use the non-thread safe version.

After learning how to select the PHP version, we will start the configuration process of IIS + php5.3 + mysql5.1 + gzip.

Step 1: manually configure php5.3
Download php5.3.2, the latest version.

Because manual configuration is more flexible and more detailed, so we introduce manual configuration PHP, so choose to download ZIP file: php-5.3.2-nts-Win32-VC9-x86.zip.

 

1. Decompress php-5.3.2-nts-win32-vc9-x86.zip to the installation directory. Here is c :\

 

2. Open the php-5.3.2-nts-Win32-VC9-x86 and create the php. ini file
Copy a new PHP. ini-development file and change the file name to Phi. ini.
For example

 

3. Open the php. ini file and modify the value of extension_dir.

 

Modify the value of data. timezone

 

Select enable module: remove the module before it is used. Note that when you enable php_exif.dll, You must place it behind mbstring to cut php_exif.dll to php_mbstring.dll.

 

When FastCGI mode is configured, set CGI. force_redirect to 0 and CGI. rfc2616_headers and FastCGI. Impersonate to 1.

 

We will use the iprober probe to check the PHP environment later, so we must enable short_open_tag = on here. Otherwise, the "iprober. php on line 910" error will occur.

 

So far, some PHP configurations have been completed. Next we will add support for PHP in IIS. Of course, we adopt the FastCGI method.

Step 2: configure the FastCGI module of IIS
There are two ways to add the FastCGI module to IIS: one is to directly download the FastCGI extension file, and the other is to use Microsoft's "web platform installer". Here we will introduce the latter.

In the first method, the name of the FastCGI extension file is:
File Name: FastCGI extension 1.5 for IIS 6.0 and IIS 5.1-RC (x86)
Http://www.iis.net/downloads/default.aspx? Tabid = 34 & I = 1877 & G = 6


This installer requires. NET 2.0 support. Make sure that. Net framework2.0 has been installed.

Next we will introduce how to configure FastCGI using Microsoft's "web platform installer.

1. FastCGI Step 1: Open Microsoft's "web platform installer":
Http://www.microsoft.com/web/gallery/install.aspx? Appid = fastcgiiis6
Open the URL and click the button in the red box below to go to the next step.

 

 

In the displayed dialog box, click Run.

 

 


The security warning dialog box is displayed. Click run again.

 

 

Next is the download web Installer Dialog Box

 

 


After the installation program is downloaded, the Web Platform is loaded.

 

 

After the installation is complete, the FastCGI installation dialog box is displayed, and click Install continue.

 

 

Next, agree to the terms, click I accept

 

 

The installation process is very fast because the file is small.

 

 

The installation will be completed later!

 

 

Finally, click exit and close IE

 

 

2. Configure in the IIS service, right-click the "website" node in IIS, and click Properties. The Properties dialog box is displayed.

 

Click the "home directory" tab, and then click "Configure ".

 

 

Click Add to add a new ISAPI

 

 

In the c: \ window \ system32 \ inetsrv directory, select fcgiext. dll

 

 

Note: Do not forget to add the. php extension here.

 

 

In the c: \ windows \ system32 \ inetsrv folder, find the fcgiext. ini file and open

 

 

Add the following configuration information at the bottom of the fcgiext. ini file:

[Types]
PHP = PHP
[PHP]
Exepath = c: \ php-5.3.2-nts-Win32-VC9-x86 \ php-cgi.exe

 

 

Now, FastCGI configuration is complete. Let's test whether the configuration is correct and copy the iprober probe program to the web directory.

 

 

Enter http: // 127.0.0.1/I/iprober. php In the browser. The output is as follows:

 

 

The following information is displayed:
PHP run mode CGI-FCGI
PHP version 5.3.2
The FastCGI mode of IIS + PHP is successfully configured!
Note: If the following error message appears:
======================================
Error details:
Error number: 14001 (0x800736b1 ).
Error Description: the application cannot be started because the application configuration is incorrect. Re-installing the application may correct this problem.
HTTP Error 500-server error.
Internet Information Services (IIS)
======================================
Visual c ++ 2008 is not installed with the vc9 Runtime Library,
Microsoft Visual C ++ 2008 redistributable package (x86 ):
Http://www.microsoft.com/downloads/details.aspx? Familyid = 9b2da534-3e03-4391-8a4d-074b9f2bc1bf & displaylang = ZH-CN
Http://download.microsoft.com/download/7/5/0/7502f4e9-1f90-4895-9259-1bde67b8b9a1/vcredist_x86.exe

Step 3: Enable gzip compression on IIS
The role of gzip will not be discussed here. You can check the information.
1. Enable gzip. Step 1: Right-click "website", click "properties", click the "service" tab, select the two items in the red box, and click "OK ".

 

 

2. Right-click the Web Service Extension node under IIS and click "Add a new Web Service extension", as shown in figure

 

 

Add an extension with the extension "HTTP compression". Note that the directory of gzip. dll is c: \ windows \ system32 \ inetsrv \ gzip. dll.

 

 

In the Web service extension of IIS, select HTTP compression and click Allow on the left.

 

 

3. Set gzip Parameters
To set gzip, you must manually modify metabase in the c: \ windows \ system32 \ inetsrv directory. XML file, metabase. XML is very important for IIS operation. If it is damaged, IIS cannot run normally. If it is heavy, the system can be reinstalled. Therefore, you must back up the file before modifying the file, the file named metabase_backup.xml in is a backup.

 

 

The following describes the specific deflate and gzip parameters:
Set the deflate compression parameters, including the file extension, script file extension, and compression ratio. We recommend that you set the compression ratio to 1. We will discuss which compression ratio is the most suitable.

 

 

Set gzip compression parameters, including the file extension, script file extension, and compression ratio. It must be noted that the compression ratio is still recommended to be set to 1.

 

 

After the configuration is complete, start IIS to make the settings take effect.

 

 

4. If you do not want to stop IIS and directly edit the metabase. xml file, follow the settings:
If you do not want to stop IIS In metabase. XML, on the IIS node, note that IIS is not a website, right-click IIS, and click "properties"

 

 

Select "allow direct configuration database editing". Do not stop IIS from editing the metabase. xml file.

 

 

5. Check whether gzip compression is enabled
If your website is published on the Internet, you can use many online detection tools and many webmasters provide them. How can you test your website on your computer and check whether Gzip is enabled, we need some software that can capture HTTP header information. We recommend httpanalyzer V4. After downloading this software, we can clearly see the role of gzip.
First, disable gzip to see the HTTP header information when gzip compression is not enabled in years:

 

 

As you can see, compression saving in is displayed as 0. We can enable gzip compression to check the HTTP header information again:

 

 

You can see that content-encoding is displayed as gzip, and compression saving on the right shows the compression ratio as 73.29%, which indicates that the compression is very effective.
With this software, you can also test the compression ratio of your website.
6. Setting the compression ratio
According to the official test data, the compression ratio of KB web pages based on different gzip levels is
Gzip Level 1 0.593
Gzip level 6 (default) 0.586
Gzip level 9 0.585
From this we can see that the compression efficiency after 1 is very low. Officially, this will consume server resources, so they strongly recommend setting it to 1, and gzip defaults to 6.
The actual test results of a forum are as follows:
Level 9: 88.7% compression ratio
Level 1: 86.7% compression ratio
Use my own website to test the data as follows:
The level1 compression ratio is 62.93%, And the level9 compression ratio is 64.30%. We can see that level1 and level9 are basically different.



Therefore, I suggest using 1. Using 9 will cause heavy loads on the server, but fewer people will feel it. If there are more people, the server load will increase, in addition, the compression ratio is limited to 1 and 9.

Step 4: Install mysql5.1
Here we will introduce MySQL 5.1.48.
MySQL is provided at the beginning of this article.
It is relatively simple to install MySQL, which is provided here.






















Since zendoptimizer does not have any php5.3 version, we cannot install it.
According to the official forum, zendgard has to be greatly changed because of the huge changes made in php5.3. Therefore, zendoptimizer will not be available until Gard is complete.

 

So far, the complete configuration of IIS + FastCGI + php5.3 + MySQL + gzip has been completed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.