The Apache web server software application, MySQL database, and PHP interpreter are separate modules that work together to allow for testing of a dynamic PHP web site. Windows has none of these modules built-in, and so they must all be installed.
While you could install them separately, it is easiest to download and install them from a single bundled package. There are several companies that build these packages, and so there are certainly a few to choose from: XAMPP, AMPSS, and WampServer being a few popular options.
Today we will be installing WampServer, because it is among the fastest and easiest solutions.
WampServer can be downloaded for free on the company’s web site.
- To get to the WampServer web site, go to www.wampserver.com/en in an internet browser.
- To see the different available download options, scroll down to the Downloads section.
- To check if your installation of Windows is 64-bit or 32-bit, press the Windows key on the keyboard, and type msinfo32, then press enter.
- To select WampServer with PHP version 5.3, click either "WAMPSERVER (64 BITS…" or "WAMPSERVER (32 BITS…" depending on if you have an x64-based PC or x86-based PC, as described above.
- To go to the Visual C++ download page, click either the x86 or x64 link, corresponding with your version of Windows.
- In order to download the Visual C++ installer, click "DOWNLOAD."
- Once the file is downloaded, run the installer.
- Go back to the WampServer page by clicking back on the browser window twice, and if necessary, click on the appropriate WampServer download link again.
- To go to the WampServer download page, this time click the "you can download it directly" link on the "Download Wampserver" pop-up, shown in the image above.
- Once the WampServer installer file downloads, run it.
- Click "Next" past this wizard’s start page, and license agreement page.
- Once you have chosen a path, click "Next." Check whether or not you want a "Quick Launch" or Desktop icon, and click "Next," and then click "Install."
- Either simply click "Open" to accept the default browser (Internet Explorer), or locate the executable file for a different browser, and click "Open."
- To finish the installer and launch WampServer, click "Next," and click "Finish," keeping the "Launch WampServer…" checkbox selected.
NOTE: If you didn’t type "/en" at the end of the web address, then you probably landed on the French version of the site. Click "English" in the top-right corner.
You are now on the WampServer web site.
You should see five different download options (at the time of this article’s publication). To narrow down which options to choose from, first we must know if our installation of Windows is 64-bit or 32-bit.
The System Information window should appear. Under "System Type", which is located a few rows from the top, the value should read as either "x64-based PC" or "x86-based PC."
If you have an x64-based PC, you will choose one of the WampServer downloads that is labeled "64 bits"; with an x86-based PC, go with "32 bits."
Now we have to choose the version of PHP and Apache, the options being either 5.3 or 5.4, and 2.2 or 2.4, respectively (at the time of this article’s publication). IU’s webserve server, for which different IU organizations and departments are hosted, has PHP version 5.2 installed (as of this article’s publication), and so we will select the 5.3 WampServer option.
You should see a "Download WampServer" pop-up warning you that you must have the appropriate Visual C++ package installed on your computer in order for WampServer to work. You may or may not already have this installed.
In order to verify this information, we can download and run the installer from the link provided.
You should now be on Microsoft’s official download page for this package.
The file should begin downloading automatically.
The installer window should appear. If it is prompting you to either "Repair" or "Remove" Visual C++, then that means that you already have it installed, and you can just simply cancel out the window. Otherwise, go ahead and go through the install wizard, clicking "Next" at each page.
We are now ensured that Visual C++ is installed, and so we can proceed with downloading WampServer.
The warning pop-up should re-appear.
You will be taken to a page that may have a short countdown timer before your download automatically begins.
The installation wizard should open.
The window indicates what version of Apache, MySQL, and PHP will be installed, as well as a few other various applications that may assist you in your future web development.
We will continue through the installation wizard.
You should now be on a page which allows you to select where WampServer will be installed. This is important. This directory will serve as the primary default location for your web sites. Thus, prevent hurdles to jump over in the future, you should choose a convenient location on one of your storage drive to hold your web files.
NOTE: Make sure there are no spaces in any of the directories in the path you choose.
WampServer will now install. After it finishes, the installer will ask which web browser you want WampServer to default to. This choice dictates which browser opens when you tab through WampServer’s configuration options in the future.
Keep in mind that whatever you choose here will not affect which browser can test your web site. You will be able to use whatever browser you like, no matter what you choose.
The default option is Internet Explorer.
WampServer will now ask you about the default PHP email. This allows you to set up which email address is used for various PHP tasks, for example, where a contact form hosted on your web site will be sent. However, in order for this to work, you’ll have to have an email server installed, which neither Windows nor WampServer comes with, or be using an email service that has one available.
We will be skipping this today, as it is unnecessary to start testing PHP sites.
WampServer should now be running.
Using WampServer to test a PHP site
If all went well, WampServer should be running. In order to verify this, look for a little WampServer ‘W‘ icon on your Windows taskbar on the right.
This icon may appear either green, red, or orange. Green indicates that the server is online. Red indicates that the server is not online. Orange means that the server is online, but there is a problem keeping it from running any sites. If you ever get the orange icon, it is very likely a "port" issue.
NOTE: WampServer uses "port 80" by default in order to connect. So does Skype. If Skype is running, then you will likely run into this orange icon problem. The easy solution is to quit Skype, "Restart All Services" in the WampServer menu, and re-launch Skype, if desired. You can disable Skype from using port 80 by default in the Skype options.
Let’s test WampServer now. First we will activate WampServer’s menu.
- To open WampServer’s menu, click the ‘W‘ icon in the taskbar.
- To test if WampServer is working, click "Localhost" at the top of the WampServer menu.
- Open Notepad, or other text editor of your choosing.
- In the text editor, type <?php phpinfo(); ?>
- To save this as a PHP file, click File, click Save As…
- Navigate to the directory you installed WampServer (default is C:\wamp), double-click the www directory. Click "New folder" and name it "testsite."
- To save our file, in the "File name" field, type " index.php, and click "Save."
- To test the newly-created PHP file, in a web browser, go to the address: "localhost/testsite"
A fly-out menu should appear.
At the bottom of the menu, you should see "Start All Services," "Stop All Services," and "Restart All Services." If the server is offline (red ‘W’ icon), you can click "Start All Services." to bring WampServer online, making the taskbar icon go green.
NOTE: If you make any changes to any configuration files associated with PHP, Apache, MySQL, or any other modules or plugins, you will have to click "Restart All Services" in order for the changes to take effect.
The default internet browser you chose earlier should launch or open a new tab, with the address being "localhost." localhost is the default alias for the root of the local server that WampServer is hosting. If all went well, you should see something like this:
If your browser displays something like what the image above shows, then congratulations, WampServer is running successfully, and you can now start creating and editing PHP sites.
NOTE: If the browser throws an error saying that it cannot find the resource, make sure that WampServer is running. Click "Start All Services" to make sure.
If the browser says something else, like “forbidden”, then it’s possible that it is an IPv6-related issue. Try the WampServer localhost actual address, "127.0.0.1" in the address bar of the web browser instead, as a simple solution.
Now that we have verified that WampServer is up and running, let’s create a test PHP document.
The root directory where localhost is pointing is in the "www" directory of WampServer’s install location. We will now create a new sub directory within that root, and save our file there.
We now have a php file in a sub-directory of our root called index.php. Let’s test it in a browser.
The browser should now execute the phpinfo() function you wrote, and display the configuration of Apache, MySQL, and PHP, that WampServer has set up.
NOTE: You didn’t have to type index.php into the address because that file name is configured as a "default" home page file name.
Congratulations, you are now ready to start testing your own PHP web sites! Remember to create a different sub-folder of the www directory to serve as the root for any web site you wish to create or work on. For example, you would create a PHPBA folder within WampServer’s www folder to serve as the root directory for the PHP: The Basics class.
Good luck with your PHP sites!