IIS Hacks: Server Resources

To all those (3 people) who need to use file_get_contents in PHP on IIS 6, you may notice it doesn’t work by default. To see if it works, place the following code into a file called test.php.

  1. <?php
  2. $content=file_get_contents(“http://www.google.com”,FALSE,NULL,0,20);
  3. echo $content;
  4. ?>

You should have the first 20 bytes of the google source code echoed back to you on the page when it is executed. If not, you may need to play with IIS 6.

Does fsockopen work?

IIS 6 by default does not allow sockets to be created on port 80 (file_get_contents works on this port, of course). This is a result of how IIS 6 accepts connections. To get file_get_contents to work, you need to enable IIS 5 Compatibility (Isolation Mode) on IIS 6. You then need to choose Low (IIS Process) under “Application Protection.” Isolation mode settings are found in the IIS Admin Interface –> Right-click on Web Sites folder and look under the Service Tab.

Related posts:

  1. WordPress 2.1.x - 2.2 Breaks PHP 4.4.4
  2. How to install PHP ISAPI on Windows 2008 IIS7 x64
  3. vBulletin / Photopost and MySQL 5

Leave a reply

...