Latest Posts

Most Popular Posts

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.

<?php
$content=file_get_contents("http://www.google.com",FALSE,NULL,0,20);
echo $content;
?>

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. Unexpected Error 0x8ffe2740 when starting FTP or IIS
  2. WordPress 2.1.x – 2.2 Breaks PHP 4.4.4
  3. vBulletin / Photopost and MySQL 5
  4. How to install PHP ISAPI on Windows 2008 IIS7 x64
  5. How to Install PHP 5.3 FastCGI on Windows 2008 IIS 7


(No Ratings Yet)

One Response to “file_get_contents on IIS 6”

  1. April 10, 2009 at 2:52 pm

    Just a word of warning: after trying this out, and then subsequently trying to switch IIS 5 compatibility mode off again, I somehow managed to render IIS completely unresponsive. I couldn’t start or stop any of the web sites, or the process itself, and eventually had to reinstall IIS on our development environment.

    Make sure you have good backups before giving this a try!

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


What do you use Virtualization for?

View Results

Loading ... Loading ...