Image may be NSFW.
Clik here to view.If you are interested in using CakePHP on an IIS server, you may have experienced a few problems here and there. Mostly, the problems arise when you are trying to integrate Cake with an existing IIS server and PHP infrastructure that is large or complicated.
Regardless, I have accumulated a few tid-bits of knowledge that may save someone an immense amount of head-scratching, so hold on to your hats.
Note: I still think Apache is the preferred server for a lot of reasons, but if you are absolutely locked into IIS, then please read below. If you think you might be moving over to Apache/Linux sometime soon, seriously consider biting the bullet now. It’s sorta like saving for retirement… the more you do early on, the less of a headache it will be later.
Dustin’s Beginner Guide To CakePHP on IIS
I am assuming you have installed PHP properly and have tested your IIS + PHP configuration for correct functionality prior to attempting the Cake install. Installing PHP on IIS is outside of the scope of this tutorial, sorry.
Configuring IIS
I used Windows XP Pro IIS 5.1 for the instructions in this guide. As I roll Cake apps onto different IIS servers and versions of Windows, I’ll be sure to share what I learn in the different environments.
- Make sure that IIS isn’t checking to see if a script exists before executing.
1) Go to your server admin panel, right-click on the web server (ex: Default Web Site) and click on properties.2) Go to the Home Directory tab at the top and click on the Configuration button near the bottom of that page.
3) Find the .php extension listed in the “Application Configuration” page that appears; click on the .php extension and then click the edit button near the bottom of the page.
4) You should be on the “Add/Edit Application Extension Mapping” page: simply uncheck the “Check that file exists” box at the bottom of the page.
5) Click OK, Click OK again, Click OK once more (you should’ve closed all the windows).
6) Now restart IIS (ie: command prompt -> IISReset).
This little process fixes a few problems and was a sort of ‘magic bullet’ for many of my troubles. If you look into how Cake works and what this check box in IIS does, you’ll have a “no duh” moment like I did.
- Double check your security permissions for the Cake folders/files you dropped into your web root. Just remember that something unzipped to the desktop and copied into your Inetpub directory will often have security permissions that will prevent the server from accessing some files properly.
- Remember that the app/temp folder must be writeable by the web server (for caching). That particular problem had me scratching my head once or twice.
Configuring Cake
1) Drop Cake somewhere inside your web root.2) Go to the APP/Config folder within your cake directories. Simply un-remark (‘BASE_URL’, env (‘SCRIPT_NAME’)) at the top of the core.php config file.
You should now have a working CakePHP application inside an IIS environment. I have assumed that “pretty” URLs aren’t of great concern to you. If you absolutely must have pretty URL’s, consider a good mod-rewrite filter for IIS like Helicon Mod-Rewrite. It’s easy to use and configure, lightweight, and free for most users. If you need it, it can be done.
If you have any hints, tips, problems, or suggestions… please contribute by leaving a comment below. I am certainly not the end-all resource here as my experience is limited to a few versions of IIS (I mostly run Apache anyways).
Share your knowledge, and help make CakePHP a viable option for everyone!