WISP – PHP on Windows 2012 / IIS 8 / SQL 2012

While a LAMP is an easy and effective solution for most cases, it doesn’t always make sense in large enterprise. An organization with a large active directory domain, hundreds of servers, and the full suite of Microsoft products is going to be more comfortable with a Windows server than a one-off Linux machine. This doesn’t mean Windows shops must be .Net shops. In this post, I’ll cover how to install IIS, SQL Server and PHP 5.4.

Installing IIS

IIS is a role in Windows Server 2012.

  1. Open Server Manager
  2. Click Add Roles and Features
  3. Click Next until you get to the Role Selection pane
  4. Check off Web Server (IIS)
  5. Click Next until the wizard finishes.

Installing SQL

Before installing SQL Server you should install .Net 3.5. It’s a feature and is added through server manager. The thing is, the installation source isn’t included in Windows. Apparently it’s a new feature called Features on Demand. When you add the feature, Windows will ask “Do you need to specify an alternate source path”. Pick the option for a source path and use D:\sources\sxs (or whatever your Win2k12 ISO is attached to). It’ll work from there. Do this before installing SQL or SQL will fail.

I installed SQL Server 2012 Express edition. The features are all the same, with the exception of database size and replication. It’s a pretty standard Microsoft Wizard installation, with a few points to watch:

  • When asked to create an instance, accept the default “SQLEXPRESS”. Don’t switch to “Default Instance”. The PHP MSSQL driver fully supports named instances.
  • Select mixed mode authentication (Database and Windows Integrated).

AdventureWorks2012 Database

The AdventureWorks2012 database is the sample data which is is available for SQL Server 2012. If you’re looking for Northwind Traders, it seems they folded during the financial collapse of 2006.

The database file is downloaded from here: http://msftdbprodsamples.codeplex.com/releases/view/55330

  1. Extract the file and save it to C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\
  2. run sqlcmd -E -S localhost\SQLEXPRESS
  3. Execute the below commands to attach the DB
create database AdventureWorks2012 on (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\AdventureWorks2012_Data.mdf') FOR ATTACH_REBUILD_LOG;
GO;

Installing PHP

And finally the good stuff! PHP is installed with the Web Platform Installer. It’s a one-click install and has taken all of the hassle out of setting up PHP.

  1. Download and run the Web Platform Installer
  2. Search for PHP in the search box
  3. Click Add next to PHP 5.4 and Microsoft Drivers 3.0 for PHP 5.4 for SQL and IIS.
  4. Click Install

The WPI will resolve any dependencies and install PHP. When it’s done, that’s it! Save the below as phpinfo.php in C:\inetpub\wwwroot and try it from your browser.

<?php
phpinfo();
Advertisements

About robertlabrie
DevOps Engineer at The Network Inc in metro Atlanta. Too many interests to list here, check out my posts, or look me up on LinkedIn

3 Responses to WISP – PHP on Windows 2012 / IIS 8 / SQL 2012

  1. Pingback: COMPUTACION | I.E.S.T.P. DE "CONCEPCION"

  2. Abdullah says:

    Can you provide links to the php files?

  3. I have a 500 error message can you help me plz

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: