first got interested in running PHP using the Windows operating system during a business trip to Toronto. I was staying with my cousin who, like many people, uses Windows exclusively. My dilemma: I wanted to test out some PHP code but didn't want to upload it to my FreeBSD box until I knew it was working. This article explains how to set up Apache, PHP, and MySQL on a Windows desktop to create a testing environment for PHP code.
A look into the Windows world revealed that PHP, Apache, and MySQL have made some serious progress in Windows compatibility. The MySQL, PHP, and Apache teams have done an excellent job of producing a Windows installer for each of these applications. What's more, the PHP team has branched out to make PHP compatible with a number of servers, including Microsoft PWS, IIS, Apache, and Xitami.
Both Apache and PHP work well with a number of databases. I choose to use MySQL (foremost) because it is free and (second) because it is stable. The combination of Apache, MySQL, and PHP empowers a developer to set up a robust, database-driven Web site testing area for nothing more than the cost of a computer. To ease this install, you can download the Windows Apache, PHP and MySQL files.
Installing the Trio
Part of the trick to installing this power trio is to do so in the correct order:
Decide where you want to insert the MySQL directories. The default location is C:\mysql, which is perfectly fine. Unless you have a specific reason for installing them to different locations, install each of these three applications to its default directory.
Windows 95/98 users should use Apache 1.3.31. All other Windows users should be fine with Apache 2.0.49. If you have IIS or another server installed already, you don't need to uninstall it. Your other server(s), however, will have to be shut down while Apache is running. Simply choose where you want to install Apache. I recommend C:\apache2. When prompted, set your domain name to localdomain and your host address to localhost (see Figure 1).
|Figure 1: Configuring for localdomain and localhost with Apache 2|
As you install PHP, you will be prompted to choose a server with which to work. In this case, choose Apache (see Figure 2
|Figure 2: Choose Apache as the Server Type|
- Navigate to the folder where you installed PHP (the default is C:\PHP\).
- Copy the file php4ts.dll to your system directory (e.g., winnt/system32 or windows/system).
- Navigate to C:\PHP\BACKUP (or wherever you installed PHP) and copy the file php.ini or php.ini-dist to C:\windows for Windows 95/98 users or to C:\winnt or C:\winnt40 for Windows 2000/NT/XP users.
- After you have copied the php.ini-dist file, rename it to php.ini. The php.ini file is integral to manipulating the PHP language. To extend the capabilities of the default PHP installation, you must edit the php.ini file.
Almost there… now restart your machine to put the Apache options into your start menu.