Setting Up CakePHP with IIS

Published on Jun 11, 2013 by Jamie Munro

Iíve found myself doing this several times over the past little while as I had to switch computers.† Each time I would struggle with a few of the steps, so I thought I would document them this time and share for future me (or you if you like).



Install IIS


The first thing that needs to be done is to actually install IIS.† This is done through the Control Panel.

  1. Open Control Panel

  2. Click on Programs

  3. Under Programs and Features, select Turn Windows Features On or Off

  4. Find the folder called Internet Information Services (what IIS stands for) and expand it

    1. Expand Web Management Tools




i.††††† Select IIS Management Console

  1. Expand World Wide Web Services


i.††††† Expand Application Development Features

  1. Select CGI, ISAPI Extensions, ISAPI Filters

  2. Optionally, you can select the .NET ones if you need them


ii.††††† Expand any of the remaining sub folders and select any items that may interest you in turning on

  1. Click OK


Itís important to note, that by default my IIS was already turned on; however, under Application Development Features, the CGI option was not and after installing PHP I had the following error:

Error - "Handler "PHP53_via_FastCGI" has a bad module "FastCgiModule" in its module list"

Luckily, a quick Google search brought me here to tell me how to solve the issue: http://www.hagrin.com/344/fixing-http-50021-error-handler-php53viafastcgi-has-bad-module-fastcgimodule-its-module-list was to turn on this feature!

Install PHP


I took the lazy way out.† I used the Web Platform Installer to make things easier.

  1. Open Web Platform Installer

  2. Search for PHP

  3. Click Add for PHP Manager for IIS

  4. Click Install


This will download a stable version of PHP and configure IIS to be able to handle PHP files.

If you do not perform this step, youíll have to make several changes to IIS not being covered in this tutorial!

Optional - Install MySQL


If you wish to you MySQL, follow these steps.† Once again I leveraged the Web Platform Installer.

  1. Open Web Platform Installer

  2. Search for Mysql

  3. Click Add for MySQL Connector/Net

  4. Click Add for MySQL Windows 5.1

  5. Click Install


The MySQL Connector is required to be able to connect to a MySQL database.

The MySQL Windows 5.1 is actually a MySQL server that will run locally.† If you simply wish to connect to an existing MySQL database, only the connector is required.

Download CakePHP


Visit http://www.cakephp.org and download the version of CakePHP you wish to use.

Extract CakePHP on your computer.† This should be placed into a folder that is not behind higher security.† E.g. of My Documents, Program Files, Windows Folder, even inetpub.† I would suggest creating a folder at the root of your drive of choice.

Create IIS Website



  1. Open the Internet Information Services (IIS) Manager

    1. Expand the folder with the name of the computer

    2. Click on Sites

    3. On the right select Add Web SiteÖ

    4. Select a name and a hostname (perhaps just localhost).† Click the Ö beside physical path and select the root of your CakePHP folder (when app is)




i.††††† This is important as itís different from Apache or Nginx where you would select the app/webroot!

  1. Click Ok

  2. To enable URL Rewrites (aka pretty urls), open the Web Platform Installer again

    1. Search Rewrite

    2. Click Add for URL Rewrite 2.0

    3. Click Install

    4. Visit: http://book.cakephp.org/2.0/en/installation/url-rewriting.html#url-rewrites-on-iis7-windows-hosts

      1. Create a new file called Web.config in the root of your CakePHP folder (where App is)

      2. Paste the contents from the code block in the above page






Up and Running


At this point you should be up-and-running.† You will need to finish off the remaining regular configuration of CakePHP such as setting up your database connection, changing the cipher in core, etcÖ

See the CakePHP Getting Started Guide for any further information.

Summary


Once youíre done, feel free to browse the ton of CakePHP sample code Iíve blogged about in the past!

Tags: CakePHP | php | PHP | mysql | iis

Related Posts

blog comments powered by Disqus