We have one internal web server at work that was running Windows 2003 server and a very old version oh PHP. So it was time to upgrade this box to 2008 R2 and the latest version of PHP. I thought that this was going to be a pretty easy migration and should be done in a couple of days and we could power off the old box. Not so much. PHP has changed since the last time I installed it. Microsoft wants you to use it’s PHP drivers instead of you using the built in MSSQL commands. Since I couldn’t find anything in on place I am now going to post what I got to work.
PreReqs
1. Download the latest version of PHP (5.4.3 at the time of writing this) Download Link
2. Download the latest version of PHP MSSQL Drivers (3.0.1 at the time of writing this) Download Link
3. Download the latest version of PHP Manager for IIS (1.2 at the time of writing this) Download Link (this is not needed but makes it easier to manage PHP on IIS
4. Download the Microsoft SQL Server 2012 Native Client Download Link
Installing IIS
1. Launch Server Manager and go to roles
2. Add Roles
3. Add the Web Server (IIS) role
4. Make sure that CGI
5. Click install
6. Test to make sure that IIS works by going to local host from a web browser installed on the server
Installing PHP
1. Extract PHP to a directory of your choice. For this article I will extract it to C:Program Files (x86)PHP
2. Open Inetmgr
3. Click on the Server in the tree
4. Open up Handler Mappings
5. In the Actions side bar click on Add Module Mapping
6. Fill in your fields like the ones below
7. Before clicking ok click on Request Restrictions and fill in your fields like the ones below
8. Click ok until you get back to the main Internet Information Services Manager Screen (Note: You will get a screen asking you to create a FastCGI application, Click Yes)
9. Close the Internet Information Services Manager Screen.
10. Copy the php.ini-production file and rename it to php.ini
a. Make the following changes to php.ini
i. fastcgi.impersonate = 1
ii. fastcgi.logging = 0
iii. cgi.fix_pathinfo=1
iv. cgi.force_redirect = 0
11. Install PHP Manager for IIS
12. Reopen Internet Information Services Manager
13. Go to the Main Server Screen and open PHP Manager
14. PHP Manager will tell you about any non optimal configuration settings. Fix any of these that you see fit
15. Test php by clicking on check phpinfo in PHP Manager. If successful you should see something that has the php.net logo on it.
Install Microsoft SQL PHP Support
1. Install the SQL Server 2012 Native Client
2. Extract the PHP SQL Drivers to your system.
3. Copy the php_sqlsrv_54_nts.dll and php_pdo_sqlsrv_54_nts.dll to C:Program Files (x86)PHPExt
4. Open Up Internet Information Services Manager and go to PHP Manager
5. Click on Enable or disable an Extension
6. Enable both the dll’s from step 3
7. Restart the server
8. Open up Internet Information Services Manager and go to PHP Manager
9. Click on Check phpinfo() and make sure you have an entry for sqlsrv.