IIS7 IIS7.5 upgrade PHP5.3 site slow down solution

  • 2020-05-12 06:28:06
  • OfStack

Most PHP pages are actually database-driven, requiring a connection to the database to be displayed, and the response time is too long because of a change in the way PHP 5.3 connects to the database. Currently we configure database information like "$dbhost= 'localhost'"; There is no problem with this in itself, except that PHP 5.3 will consider whether to use IPv4 or IPv6, and will hesitate when facing localhost, so the response time is too long. If you look at how long the server has been processing PHP, you will find that the processing time for PHP is short and the waiting time is long.

That is, the time it takes to locally parse localhost at 127.0.0.1 when connecting to the database is too long

At present, this kind of over-response time only occurs after IIS 7 and IIS 7.5 upgrade the PHP 5.3 series. It doesn't matter what the database version is. Simple popularization 1, windows 2008 is divided into 32-bit and 64-bit, with IIS 7, windows 2008 R2 with IIS 7.5, R2 version of the system is only 64-bit. If you are using IIS 6 or Linux or something like that, there are no such problems yet, mainly windows 2008.

Solutions:

Method 1: as mentioned above, this is because PHP 5.3 would hesitate to "localhost" in the face of database configuration information, so simply change the address to "127.0.0.1", for example:



  <?php
  // Database connection information
  $cfg_dbhost = 'localhost';   // To change this localhost for :127.0.0.1  
  ?>

Method 2: IIS 7 and IIS7.5 turn on IPv6 components by default. Many large domestic manufacturers are also deploying IPv6. If your server doesn't have access to the IPv6 network, disable IPv6.

Open the file "%systemroot%\System32\drivers\etc\hosts" and comment out "::1 localhost".

Method 3: just downgrade the PHP version to PHP version 5.2.17, which is the most used version. Almost all PHP website programs can run on this version. Both IIS 7 and IIS 7.5 have been tested to ensure efficient operation of PHP web applications in PHP 5.2 series.


Related articles: