How To Install IIS 7, PHP5 and MySQL 5.1 on Windows Server 2008 – Part 2

February 12th, 2008 · 26 Comments

Following up on my last post, I’ve now got a working IIS 7 web server running on Windows 2008. We’re now going to install PHP5 and MySQL 5.1.

PHP.netInstalling PHP5 on IIS 7

First of all, grab yourself a copy of PHP over at http://www.php.net/downloads.php. I always use the zip package, I never use the installer. The installer only installs and configures the CGI version of PHP which is not the best solution for an IIS web server. I prefer using the ISAPI version.

At the time of this writing, the latest PHP version is 5.2.5.

  1. Download the latest PHP version for Windows and unzip its content in a temporary folder on your hard disk.
  2. When you’re done, create a folder named php at the root of your hard drive (e.g.: c:\php).
  3. Move all the content from the extracted archive to c:\php
    php-dir.jpg
  4. Rename the file c:\php\php.ini-recommended to c:\php\php.ini and open it with your favorite text editor (no word processor).
  5. Find the extension_dir parameter and set its value to “c:\php\ext”. Save the file and exit the editor.
  6. Launch the registry editor: Start => Run => regedit
  7. Create a new key named PHP under HKEY_LOCAL_MACHINE\SOFTWARE\
  8. Right-click on the newly created key and select New => String Value
  9. Name the new value IniFilePath and set the value data to C:\php
  10. Click on Start => Settings => Control Panel and double-click the System icon (using the class view).
  11. Click on the Advanced system settings link from the left column.
  12. From the System Properties window, click on the Advanced tab and then on the Environment Variables button at the bottom.
  13. Select the Path variable from the System Variables section and click on Edit. Add c:\php to your system path (be sure to include the semi-colon separator).
    windows2008-system-properties.jpg
  14. Click on OK until you’ve exited the System Properties window .
  15. Launch the Internet Information Services Manager: Start => Programs => Administrative Tools => Internet Information Services (IIS) Manager
  16. From the IIS Manager, click on your server’s hostname from the Connections panel on the left. Double-click on Handler Mappings icon.
    iis7-handler-mappings.jpg
  17. From the Handler Mappings actions panel, click on Add Script Map…
    iis7-add-script-map.jpg
  18. Fill-in the information as illustrated below and hit OK:
    iis7-php-script-map.jpg
  19. Click again on your server’s hostname from the left panel and double-click on the ISAPI And CGI Restrictions icon.
  20. From the Actions panel on the right click on Add…
  21. Enter the information to allow PHP processing as illustrated below and hit OK:
    isapi-cgi-restrictions.jpg
  22. Click on your server’s hostname form the left panel and double-click on the Default Document icon.
  23. Click on Add… from the actions panel on the right.
  24. Enter index.php in the new default document name and click on OK.
  25. Click on your server’s hostname from the left panel and then click on Restart from the actions panel on the right.
  26. Create a new text document and save it to c:\inetpub\wwwroot\phpinfo.php with the following content:<?php phpinfo(); ?>

If everything is ok, you should now see the PHP information page at http://your-server-name/phpinfo.php:

windows2008-iis7-phpinfo.jpg

Stay tuned for my next post on how to install MySQL 5.1 on Windows 2008.

26 responses so far ↓

1. Response by : Bill Staples on Feb 12, 2008 at 5:44 pm

Be sure and also check out the new fastCGI feature available for IIS 6 and IIS 7. It allows PHP to run much more reliably on IIS, with great performance. I recommend it over the Isapi based PHP referred to above. See http://iis.net/php for more information.

2. Response by : Stephane Brault on Feb 13, 2008 at 9:04 am

Hi Bill,

Thank you for pointing that out. I’ll look further into fastCGI and make it a future post.

Thanks!

3. Response by : grncobra on Feb 25, 2008 at 6:31 am

the tutorial was good, but i noticed that we were editing the php configuration file “c:\php\php.ini” but the output of the script “phpinfo.php” indicated that the configuration did not load(configuration file loaded = none) and its path was “C:\Windows”(configuration file path = c:\windows), when it was suppose to be “c:\php”, the one we previously edited.

4. Response by : Stephane Brault on Feb 25, 2008 at 7:36 am

Steps 6 to 9 are where you create a registry key that sets the path for php.ini

Still you should have a look at how to install PHP with FastCGI instead: http://www.thewebhostinghero.com/tutorials/windows2008-iis7-fastcgi-php.html

5. Response by : Ahmed on Feb 26, 2008 at 11:24 pm

this what I got after following your instructions:

HTTP Error 404.0 – Not Found
Description: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Error Code: 0×8007007e

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/phpinfo.php

Physical Path: C:\inetpub\wwwroot\phpinfo.php

Logon User: Anonymous

Logon Method: Anonymous

Handler: PHP-ISAPI

Most likely causes:

The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.

can anyone tell me what am I doing wrong here please?

thanks

6. Response by : Ahmed on Feb 27, 2008 at 6:28 am

ok.. I deleted all the files of php and deleted everything I did for installing it.. and started everything again.. everything went fine.. but this time, when I finished everything and when I opened as said in this tutor.. the error has disappeared but the problem is that nothing showed up in the page.. only white blank page.. after that I found in some webs someone who says to write this html code in the phpinfo.php file instead of the one you said in here

here is the code

PHP Information

the question is: did I do something wrong or everything is ok?

and why didn’t anything showed in the page when I put the first code but when I put the html code everything showed up as it supposed to be?

I’m just a newbie in php and I hope you can help me..

thanks

7. Response by : Stephane Brault on Feb 27, 2008 at 6:59 am

Hi Ahmed,

Try installing PHP with FastCGI instead:

http://www.thewebhostinghero.com/tutorials/windows2008-iis7-fastcgi-php.html

8. Response by : mike on Mar 14, 2008 at 2:26 am

Followed this to the T, however it didn’t work. Replaced all reference to the isapi with the fastcgi and everything worked well.

Now I only hope that mysql will co-operate with server 2008 and wordpress, as it hasn’t in the past with me.

9. Response by : mike on Mar 14, 2008 at 10:14 pm

Update: What an excellent finish! After using fastcgi instead of isapi module and using very specific builds of all 3, I was able to get WordPress working! Point yourself over to http://blackboxdisease.wordpress.com/2008/03/15/wordpress-on-server-2008/ for the specific builds if you plan on running WordPress on Windows Server 2008

10. Response by : Morten J on May 30, 2008 at 2:04 pm

Hi.

I have followed your guides til install IIS, php, mysql and also added phpmyadmin.

When i try to excute a php script in a sub folder called wiki, i get the following error.

Writing C:\inetpub\wwwroot\wiki/data/cache/4/47b30de29a264c3bf6f48377ac6a6953.i failedUnable to save cache file. Hint: disk full; file permissions; safe_mode setting.

And this one…

Writing C:\inetpub\wwwroot\wiki/data/cache/4/47b30de29a264c3bf6f48377ac6a6953.xhtml failed

I have added the IUSR_SERVERNAME to the wwwroot and also to my wiki sub folder, but it doesnt seem to help.

Can you help me out here?.

11. Response by : Stephane Brault on May 30, 2008 at 2:33 pm

Hey Morten,

I’d be tempted to say that your hard drive is full but I guess you verified that?

Also, which wiki are you trying to install? MediaWiki?

12. Response by : Morten J on May 31, 2008 at 6:20 am

Hi again.

My HD is not full, theres 17GB free. Its DokuWiki im trying to run on it and I should also mention that my w2k8 is running from vmware fusion…Mac.

I was wondering about this path: C:\inetpub\wwwroot\wiki/data…. can that be correct with the \ first and then a / next in the path?.

13. Response by : Stephane Brault on May 31, 2008 at 7:14 am

Does your cache directory exists and does it have full write access? I’m not familiar with DokuWiki but I’ve found this, perhaps it may help you:

“I’m running a DokuWiki on IIS on our intranet. It appears to work just fine so far. You need to have PHP installed, give the IUSR user write rights if you are to have anonymous access (if I was hosting this on the Internet I’d take some time working out which files/folders need ‘write’ access and limit the write rights to just those), make sure the ‘attic’, ‘cache’, ‘locks’, ‘media’ folders exist in the root ‘data’ folder, and create a change.log file in the ‘data’ folder. You also have to give the IUSR user ‘modify’ rights if they are to delete pages.”

As for the slash / backslash thing, I happen to see some cases where it didn’t matter and sometimes it did.

DokuWiki seems to be made to run on Apache in the first place so maybe you wanna try that out.

14. Response by : Stephane Brault on May 31, 2008 at 7:16 am

15. Response by : Morten J on May 31, 2008 at 3:59 pm

Thx alot for youre time and tips Stephane. I will try some other php scripts out in the next days to test the server out. I didnt know that about DokuWiki.

As for the IUSR: it has full access all the way down in the file structure.

Also thx for these great guides :)

16. Response by : quick question regarding c and php. - TalkPHP on Jul 10, 2008 at 12:47 pm

[...] to install PHP on IIS: BillS IIS Blog How To Install IIS 7, PHP5 and MySQL 5.1 on Windows Server 2008 – Part 2 …seems to make it sound fairly simple. [...]

17. Response by : chris on Aug 28, 2008 at 2:49 pm

Can’t get this to work in any shape or form. Any help here would be appreciated. Using Vista business, IIS7 works until I add PHP which kills it dead.

18. Response by : chris on Aug 30, 2008 at 2:44 pm

Sorry had to repost, Ok if i install IIS7 it works, but if I add any reference to PHP be it via Isapi or FAST-CGI then IIS dies ungracfully. The progress loading bar goes slower than a snail with one leg, then freezes half through. I am using a new laptop which I bought specifically to use as a portaable development machine and it would appear that I have nothing but an expensive useless brick

19. Response by : Aaron on Oct 6, 2008 at 5:20 pm

Hello! I just want you to know you’re my hero for making this tutorial. I ran into a problem with “The specified module required by this handler is not in the modules list,” but it’s because a certain feature/service of the website role wasn’t installed. For those getting the same error I did make sure you install all the same features/services that are listed in the first part of this tutorial. Thanks again!

20. Response by : Miki Szikszai on Oct 9, 2008 at 7:22 pm

Hi

Noticed you have virtual directory support enabled in your PHP settings – how did you do this please?

Cheers

Miki

21. Response by : mani on Jan 7, 2009 at 4:13 am

this what I got after following your instructions:

HTTP Error 404.0 – Not Found
Description: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Error Code: 0×8007007e

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/phpinfo.php

Physical Path: C:\inetpub\wwwroot\phpinfo.php

Logon User: Anonymous

Logon Method: Anonymous

Handler: PHP-ISAPI

Most likely causes:

The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file

after What can i do?

22. Response by : mani on Jan 7, 2009 at 7:35 am

thx for these great guides….

23. Response by : n2uga on Feb 26, 2009 at 11:53 pm

In the end all that was causing the issue is that by default a new install of Windows 2008 Server hides known file extensions by default. So when I installed PHP, right clicked in the webroot and selected new text document and saved as phpinfo.php the file was actually saved as phpinfo.php.txt. Simple as it is I can tell you this little gem had me stumped, and then a little red faced when I found the problem.

So should you find yourself facing the same dreaded “No input specified” error, take a moment and ensure that you have cleared the “Hide file extensions for known file types” tick box. This can be done from the Views tab under the Folder Options menu item from in the Tools menu in Windows Explorer.

24. Response by : Erik on Mar 28, 2009 at 5:28 pm

I had some weird problems for weeks now trying to solve the No input file specified error.
And all I found on the web couldn’t help me.
As I used to recall similair strange errors with a IIS6/W2K3/PHP5/MySQL5.x, I got back to the basics.
And as always, it is the compatibility between extensions from PHP versus MySQL.

One which succesfully works: PHP 5.2.9-1 & MySQL 5.0.77
Any other combination of higher versions of MySQL will definately give you trouble.

As for what I tried in any order:
- Switched of EXIF extension as it has caused trouble
- Never used the doc_root = , so was already empty/disabled also
- Had minor succes moving PHP from C:\Program Files\PHP to C:\PHP
- Tried other PHP versions versus MySQL 5.1
- Multi host environment weirdo: Site 1 works, Site 2 doesn’t especially with pages using MySQL

So finally, back to one which succesfully works: PHP 5.2.9-1 & MySQL 5.0.77

25. Response by : rjm on Jun 4, 2009 at 12:32 am

Wow, incredible, perfect writeup on how to install PHP on W2008S. Thank you very very much ! It couldn’t have been better.

26. Response by : Dustin on Jun 26, 2009 at 12:26 am

This is the most clear description of the install I have seen yet… but I can’t get it to work :( I have set up IIS as you did in the previous post and configured PHP and my IIS data. I am getting a 404.3 Error : “The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.”

I don’t understand because I have the ISAPI mapping and the dll is present. Is there any other configurations I can check?

Leave a Comment




Recommended Web Hosts

 
 

Tutorials by Category

Recent Comments

Recent Webmasters

 
© Copyright 2009 - TheWebHostingHero.com