How to Install PHP on IIS 6.0

I just found myself needing to install PHP manually on a Windows 2003 VPS server using IIS 6.0. While I’ve use PHP before, I am by no means an expert on it and this was to be my first installation.

Since I needed a secure environment, I needed to install PHP manualy (rather than with the MSI). I downloaded PHP and started following the instructions on php.net. The documentation wasn’t bad but seemed a bit more complicated than it needed to be.

As I was clicking from one page to the next I noticed a comment at the bottom of the page from someone named Paul Lynch who said he wrote a simple set of instructions. Curiosity, and the promise of simplicity, got the best of me so I followed the link.

I couldn’t be happier with my decision. Paul’s tutorial is simple, informative and to the point. I finished up the installation and had a test page working in less than 10 minutes.

For anyone looking for a PHP installation guide, I highly recommend checking out Paul’s tutorial.

-rG

Windows vs. Linux Directory Sorting

I’m developing a site on a Windows host for a client whose site is hosted on Linux and just ran into an unexpected issue. My PHP code is supposed to display all of the images in a particular folder on a page. I renamed all of the images so they’d be read in the order I wanted them displayed. My code looked something like this:

$path = ‘images/thumbs’;
$folder = dir($path);
while($img=$folder->read()) {
if($img== “.” || $img== “..”) continue;
echo ‘
<div id=”imgPod”>

    <div id=”image”>

      <a href=”images/’.$img.'” <img src=”‘.”$path/$img”.'” /></a>

    </div>

</div>’;
}

The sorting worked like a charm on my host but when I published it live the images were scrambled. Turns out Linux doesn’t read the files in alphabetical order. What I had to do instead was to first read the filenames into an array, then sort the array and display the images in the order of the newly sorted array. The new code:

$path = ‘images/thumbs’;
$folder = dir($path);
$img_array = array();
while($img=$folder->read()) {
if($img== “.” || $img== “..”) continue;
$img_array[] = $img;
}

sort($img_array);
foreach ($img_array as $image) {echo ‘
<div id=”imgPod”>

    <div id=”image”>

      <a href=”images/’.$image.'” <img src=”‘.”$path/$image”.'” /></a>

    </div>

</div>’;
}

Not much extra coding and it worked great.