This tutorial will walk you though setting up a functioning Windows-Apache-PHP-MySQL + CakePHP installation on Windows XP. This tutorial should also work for Windows 2000 or Vista, but since I’m not testing in that environment you should know that this was written with Windows XP in mind.
Assembling the Software
- Apache 2.2.x- http://httpd.apache.org/download.cgi : Download the “Win32 Binary without crypto (no mod_ssl) (MSI Installer)” unless you plan on using SSL Apache features in your development environment.
- PHP 5.2.6 -http://us.php.net/get/php-5.2.6-Win32.zip/from/a/mirror : Select a mirror and download the zip version. While there is an installer version available, I find that the zip version is so easy to install it’s hardly worth using the installer.
- MySQL 5.0.67 - http://dev.mysql.com/downloads/mysql/5.0.html#win32 : Download the Windows Essentials (x86) version by clicking Pick a Mirror. You will be asked to create an account or sign in. You can SKIP this step by clicking the “No thanks…” link underneat the login form. Select a download location and download the application.
- CakePHP 1.2 RC2 -http://cakeforge.org/frs/?group_id=23&release_id=399 : Select the ZIP version to download to your computer.
Now you’ve got all the parts you’ll need to begin.
INSTALLING APACHE
Double-click the installer icon and run through the setup. I don’t like diving into a ton of sub-directories for my Apache installation so I typically change the installation destination to: C:\Apache\. Aside from that all the default options are just fine.
To test that you’ve got Apache up and running just point your browser to: http://localhost/ and you should be greeted with a message like “It Works!”
[NOTE: There are many reason this may fail on your machine and there are plenty of support resources available on the web to help you troubleshoot. This information is provided as-is.]
INSTALLING PHP
- Create a directory for PHP. I like to use C:\PHP and examples moving forward will treat it as such.
- Unzip the PHP package to the C:\PHP directory you just created.
- Rename php.ini-recommended to php.ini
- Edit the php.ini file you just created and make the following changes:PURPOSE: Tell PHP where to find extensions that it’ll need for specific features.
Find:
;extension_dirChange Line:
extension_dir = “C:\php\ext”PURPOSE: Tell PHP that you’d like to use MySQL.Find:
;extension=php_mysql.dll
;extension=php_mysqli.dllChange Line:
extension=php_mysql.dll
extension=php_mysqli.dll - Now we need to make PHP work in Apache so open C:\Apache\conf\httpd.conf and add the following lines:PURPOSE: Tell Apache where it can find PHP and add the .php extension as a recognized file format.# For PHP 5 do something like this:
LoadModule php5_module “c:/php/php5apache2_2.dll”
AddType application/x-httpd-php .php# configure the path to php.ini
PHPIniDir “C:/php” - Finally in the already open httpd.conf file we need to add index.php as a directory index so that our server will know that when we type in index.php it is a valid index file.FIND:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>CHANGE LINES:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule> - Restart Apache by double-clicking on the Apache Monitor icon in the taskbar (by the time) and selecting ‘Restart.’
If everything was successful you should see Apache/2.2.x (Win32) PHP/5.2.6 in the bottom status bar for the Apache Service Monitor window. Sometimes you may need to close this window and open it again to see it.
INSTALLING MYSQL
I’d love to give you more specific advice here but really just run the installer. Once the installer has completed it’ll ask you if you want the default settings or if you’d like to go through the guided setup. Select that you’d like to go through the guided setup. I leave everything the same except the following choices:
- Add MySQL as a Service called MySQL
- Add MySQL/bin to the Windows PATH (Sets up everything you need to run MySQL from the command prompt in Windows)
- I then set my root password. (Remember…it may be tempting to have everything run as your root user, but you should be taking the time to set up specific users for each application so that a comprimise in a single app, even on a dev box, won’t comprimise all the apps.)
At this point I like to restart my computer. Why you ask? For some reason I can never get PHP, Apache & MySQL to play nice without a restart first.
INSTALLING CakePHP
- Create a subdirectory in C:\PHP called Cake1_2. You should have a directory called C:\PHP\Cake1_2\ now.
- Unzip the contents of the CakePHP RC2 download into this new directory.CakePHP comes with a cool built in console interface, but you won’t be able to use it if you don’t follow these steps:
- Right Click on My Computer & select Properties
- Click the Advanced Tab
- Click the Environment Variables button at the bottom of the tab
- In System Variables (bottom scrollable windows) scroll down until you get to Path. Highlight it and click the Edit button underneath that area.
- Put your cursor at the end of the line and add a semi-colon if one isn’t already there and add:
c:\PHP;C:\PHP\cake1_2\cake\console; - Click the OK button
- Click the OK button or close out of the System Properties box
Now…
- Click Start
- Click Run
- Type cmd
- At the command prompt type: echo %PATH%
- You should see the entries we just added. If you don’t see them then you can restart your system for a quick fix or you can just wait and they will be added on the next system refresh I believe.
Once you see the new paths in the %PATH% variable try this to verify the installation:
- Click Start
- Click Run
- Type cmd
- At the command prompt type: php -v
- At the command prompt type: cake
You should have seen the version information for php and the help system for the cake console.
You can now begin development with cakePHP on your Windows XP machine.
FINAL DISCLAIMER: This information was put together on September 13th, 2008. Not all machines are configured the same way and this may cause issues with getting your system working following these instructions. I have found these steps to be repeatable across many different machines, but as stated it may not work for you. Each tool listed has great support communities to help you if you run into any problems. I am providing the information “as-is” and will not be providing technical support for people who run into issues.



Leave a Reply