WAMP Up Your Open Source Development on Windows for Free

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:

  1. MySQL
  2. Apache
  3. PHP

MySQL
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.

Apache
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

PHP
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
  1. Navigate to the folder where you installed PHP (the default is C:PHP).
  2. Copy the file php4ts.dll to your system directory (e.g., winnt/system32 or windows/system).
  3. Navigate to C:PHPBACKUP (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.
  4. 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.

Configuring Apache
Apache needs to be configured to recognize calls to PHP. Go to your start menu ?> Programs ?> Apache HTTP Server 2.0.50 ?> Configure Apache Server ?> Edit the Apache HTTP Configuration File, and add the following to the very bottom of the httpd.conf file:

ScriptAlias /php/ "c:/php/"AddType application/x-httpd-PHP .phpAction application/x-httpd-PHP "/php/php.exe"AddType application/x-httpd-php3 .php3AddType application/x-httpd-php3-source .php3sAddType application/x-httpd-PHP .phpAddType application/x-httpd-php-source .phps

This tells Apache both where to find the php.exe file and how to handle .php calls. Close httpd.conf and save the changes.

Configuring MySQL
To configure and start MySQL, open a DOS console in one of the two following ways:

  1. start menu ?> run ?> and type cmd
  2. start menu ?> programs ?> accessories ?> Command Prompt

MySQL DOS Commands
Those of you who want to install MySQL as a service that starts every time you boot up:

TYPE C:mysqlinmysqld –install 

To stop using MySQL as a service:

TYPE C:mysqlinmysqld –remove

To manually start MySQL:

TYPE C:mysqlinmysqld --console

To manually stop MySQL:

TYPE C:mysqlinmysqladmin -u root shutdown

Setting the MySQL Root Password
You now should have MySQL running in a DOS console. Open another console window using one of the two methods described above. You need to change the default root password on your MySQL Windows install. Write your password down somewhere so you don’t forget it.

TYPE c:TYPE cd mysqlinTYPE mysql -u root

At the MySQL prompt:

TYPE SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpasswordhere');TYPE DELETE FROM mysql.user WHERE Host='localhost' AND User='""';TYPE FLUSH PRIVILEGES;

These commands change your root password and remove another out-of-the-box root user to improve your security.

Testing Time
Now that Apache, MySQL, and PHP are installed and configured, it is time to test your installation. Leave MySQL running. Apache should already be running, and the changes to the httpd.conf file are enough for Apache to know where to go when it receives .php files. Create a simple script to ensure that Apache and PHP are working together. Copy the following PHP test script to your WordPad or Notepad text editor:

PHP_TESTER

Save this file as phptester.php to the folder C:apache2Apache2htdocs. Open your favorite Web browser and enter http://localhost/phptester.php. If this is working properly, you should see the details of the PHP installation you just performed.

Using PHP to Access MySQL via Apache
Now, connect to the MySQL database using PHP code. Copy the following into your favorite text editor:

PHP_MySQL_ConnectionCongratulations! You are ready to build dynamic database-driven Web sites";} else {echo "

Back to the lab again*****Something went wrong

";}// closing the connection is considered good formmysql_close ($Connection);// close the php?>

And that is that. If you made it this far you now have the MySQL database, the Apache Server, and the PHP language working with each other. The Apache, PHP, and MySQL developers certainly have made high-quality products. Good luck with all your coding.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS