How to Install and Configure Apache, PHP, Perl and MySQL on Windows the Easy Way

Test your site on your own computer with the help of XAMPP

How to Install and Configure Apache, PHP, Perl and MySQL on Windows the Easy Way (with XAMPP)

by Christopher Heng,

This article shows you an easy way to install and configure Apache, PHP, Perl and MySQL on your own Windows computer, so that you can test a temporary version of your website before transferring it to the Internet for the rest of the world to use.

The Software

While it's possible to install Apache, PHP, Perl and MySQL separately, you will do it here with the help of a (free) third party pre-packaged bundle, called XAMPP, that makes the process almost painless.

For Development Purposes

As mentioned above, this article is meant for those who want to install these pieces of software for development purposes. That is, you will be using them to develop and test your website before committing it "live" to the Internet. It is not meant for those who want to host their site on their own computer, and expose that computer to the Internet.

This is very important to note, because the software as it stands is not configured for such production use. The default settings are designed to make it easy for you, the webmaster, to develop and test your site. They are not secured, as they need to be, for a site visible on the Internet.

In fact, my personal preference is to disconnect completely from the Internet every time I start the web server up to test.

Who Can Benefit

I'm sure that there will be a few new webmasters who arrive at this article thinking that it applies to them because it lets them experiment with creating a website before putting one "live" onto the Internet.

However, in reality, the average webmaster, who is using a web editor software to design a website will probably not gain much by installing Apache. If you use a web editor, your website files are saved on your own computer, and you can already view them with a web browser. Installing a web server in this case is overkill.

The people who will probably find this useful are the web programmers, who are developing their own web-based software. That is, they are writing actual computer programs that only work when run on a web server, and want to test it before deploying it to their website. If you don't fall into this category of people, chances are that installing your own web server is just going to waste your time and increase your workload. (Please note that you do not need to do this even if you design your website directly in HTML. Writing HTML is not web programming. See What is HTML? What is PHP? for more information.)

Download XAMPP

Go to the XAMPP website and download XAMPP. Although this tutorial only deals with the installation of XAMPP on Windows, there are also packages available for Mac OS X and Linux if you have those systems.

If you are presented with multiple versions to choose from (for example, some packages include PHP 5.6.x, others 7.0.x, 7.1.x or 7.2.x), select the package that most closely matches the versions of software used by your web host for your site. For example, if your "live" website has PHP 5.6.x, choose a package with a PHP interpreter of the same version (if available). This will hopefully make your test environment more similar to your site's actual situation when it is finally deployed.

Note that XAMPP includes a database software called "MariaDB", which is (loosely speaking) just MySQL under a different name, so if you see words like "MariaDB" instead of "MySQL", don't worry. They are, for most purposes, the same thing.

Installing XAMPP

  1. After you download the package, doubleclick it to install it.

  2. If your computer has antivirus software running, you may get a dialog box saying something like "It seems you have an antivirus running. In some cases, this may slow down or interfere [with] the installation of the software."

    In my case, I simply clicked the "Yes" button to allow it to continue. If you click "No", the installation aborts. Note that it's generally not a good idea to disable your antivirus when installing software, since that's actually the time you really need your antivirus. (It's like having air bags installed in your car, but you remove them before you take the car out for a drive.)

  3. On modern versions of Windows (Vista, 7, 8, 8.1 and 10), you will get another dialog box with a message warning you that Windows' User Account Control (UAC) will prevent you from using some features of XAMPP if you install into "C:\Program Files" (or "C:\Program Files (x86)"), and to avoid doing so.

    Click "OK". Don't worry. We will install to "c:\xampp" which will avoid those problems. I personally do not like to disable UAC, since it has its benefits.

  4. A dialog box with a welcome message will appear. Click "Next".

  5. The next dialog box, with a sub-heading of "Select components", allows you to choose the programs that you want to install.

    By default, everything is selected. It's up to you what you want to install. I normally uncheck the "Mercury Mail Server" and "Fake Sendmail" (since I don't send mail in my local test programs), "Tomcat" (since I don't run Java Servlets and Java Server Pages), "FileZilla FTP Server" (since this is my own computer, it will be silly to FTP to it just to copy files from one directory to the next) and "Webalizer" (I don't need web statistics; I'm the only visitor on that machine so I know exactly how many people visit the site and which pages he goes to; I even know his name).

    When you're done selecting, click "Next".

  6. The next screen will let you change where to install the software. I suggest leaving it at "c:\xampp". That is, do not install it to "c:\Program Files" or "c:\Program Files (x86)" or you may face innumerable problems in the future, partly due to Windows' UAC, and partly due to some software's inability to handle directory names that have spaces in them (which "Program Files" obviously has).

    Click "Next".

  7. The next dialog box, with a sub-heading of "Bitnami for XAMPP", will offer to let you know more about the installer program itself. (Note: this refers to the setup utility, not Apache, PHP, Perl or MySQL.)

    Uncheck the box "Learn more about Bitnami for XAMPP" (unless you actually want to learn about the installer), then click "Next". (Note that this guide assumes that you have unchecked that box. I have no idea what additional screens are displayed, if any, if that box remains ticked.)

  8. In the dialog box that has the sub-heading "Ready to Install", click "Next".

  9. While installing, depending on your version of Windows and whether the Windows Firewall is enabled on your computer, you may get a dialog box, as depicted in the following picture. The exact appearance may differ, depending on the version of Windows you are using (mine is Windows 7), but the message should basically say something like it is blocking some features of the "Apache HTTP Server".

    Message from Windows Firewall about the Apache web server rules

    Take your time to read the message (don't panic and click blindly). Since I don't intend to let anyone outside my computer and own network access the web server, I unchecked the "Public networks" option and put a tick in the "Private networks" box instead. You should make your own decision on this, and click the "Allow access" button when you're done. Note that if you uncheck everything, you are probably blocking the web server from accepting connections from anywhere, which will defeat the purpose of installing the program.

    The installer will then add firewall rules that will allow the server to accept connections. As a result, your computer is now less secure: with these rules, the web server can be accessed by anyone on what Windows deems to be the same network as you (in the case of the "private networks" option) or by anyone on the Internet or the same network (in the case of the "public networks" choice). To protect your machine, you may want to keep the computer disconnected from the Internet and any network when the server is running.

    In the future, when you no longer want to have a server installed on your computer, you can delete the firewall rules that were just created. On Windows 7, type "windows firewall" into the start menu, click the "Windows Firewall with Advanced Security" entry that appears, click the "Inbound Rules" in the left column to load them into the right side, and delete all the rules for "Apache HTTP Server".

  10. Uncheck "Do you want to start the Control Panel now?" and click "Finish".

Solving Compatibility Issues

If you have another web server installed, such as Microsoft's IIS, the Apache web server will not be able to respond to HTTP requests at the default port (port 80) since IIS may already be in control of it. Note that it may not be obvious that you have another server installed. For example, Windows 10 Pro comes with IIS, and if you did not set up your own machine, it is possible that it was installed when Windows 10 was set up for you.

To solve this, you have to stop the other server from "binding" port 80. For IIS, this can be done by running Services from the Start menu, stopping the "World Wide Web Publishing Service", and setting the "Startup type" field of that service to "Disabled". Note that this will probably stop IIS from working altogether (although I'm not sure). For other software, look into their options / settings to see if there's a way to make it use some other port, or find some way to terminate the program.

Starting and Stopping Apache and MySQL

To start up Apache and MySQL, type "xampp" into your start menu. A list of start menu items containing the word "xampp" will appear. Click "XAMPP Control Panel".

You will get a dialog box with two country flags the first time you run it. This is to allow you to select the language XAMPP uses. Choose either the US flag (the flag on the left in the version of XAMPP I installed) or the German one for English or German respectively, and click "Save". (Yes, it makes no sense to show a picture of a flag for a language, supposedly in a language-agnostic fashion, and then put the word "Save" on the button. You might as well just display the name of the language in the same tongue as that word. If people can read the word on the button, they can read the names of the languages.)

Once you do this, the XAMPP Control Panel will appear (see below).

XAMPP Control Panel

The Control Panel allows you to start and stop the various modules you have installed.

To start Apache, click the "Start" button that is on the same line as the word "Apache". Once the server is running, the word "Apache" will be highlighted in green and some numbers (their process ids, which are just numbers used internally by Windows to identify running programs) will be displayed in the "PID(s)" column. The "Port(s)" column will also show which ports the server is able to monitor. It should show "80, 443". If it doesn't show "80", it means that you have another web server running on your computer that is in control of that port. See the Solving Compatibility Issues section above for information on what to do.

Next, click the "Start" button for MySQL (if you have installed that). If this is the first time you are starting up MySQL, you may get a message from Windows Firewall asking whether to allow this. As before, I uncheck the "Public networks" option and select the "Private networks" box since it suits my purposes. Whatever you choose, when you're done with your selection, click "Allow access".

Note that the firewall rules for both MySQL and Apache can be accessed from Windows Firewall as mentioned earlier. If you change your mind about the rules you set (whether "private" or "public" networks or both), you can simply stop the two modules in the XAMPP Control Panel, delete the relevant rules in the "Inbound Rules" section of the Firewall, then start the modules again. You will then get the same firewall dialog box as earlier and you can redo your selection. For those who can't locate the MySQL rules, they are listed as "mysqld" in the Inbound Rules section.

Once successfully started, the "MySQL" word in the XAMPP Control Panel will also be highlighted in green.

Whenever you are done with Apache and MySQL, you can terminate them by clicking the "Stop" button on their respective lines. And of course after you do that, you can quit XAMPP by clicking the "Quit" button.

For those who are wondering why PHP and Perl do not have their own entries, those programs will be invoked by Apache as and when needed. (They don't run all the time; they are started only when there is a PHP or Perl program to process.)

How to Configure Apache

Unlike a pristine installation of Apache, where you have to do things like enable support for server side includes, PHP and Perl manually, the XAMPP package has all these things already pre-configured. As such, you don't need to do anything special to enable them. In other words, your task of getting Apache to work on your computer is done.

However, should you ever need to adjust any of the settings in the server, the configuration file can be accessed by clicking the "Config" button in the Apache line of the XAMPP Control Panel, and "Apache (httpd.conf)" in the menu that pops up. The Windows Notepad editor will open with the configuration file loaded, and you can manually adjust the settings as needed.

How to Configure PHP

Similarly, the PHP bundled in XAMPP is already configured to work with MySQL so you don't have to do it yourself the way you would if you were to install MySQL and PHP separately.

In addition, it is also already set up to display all error messages in your browser, which is very useful on a development machine so that you get immediate notification of problems when you are testing your program. (Configuring things this way is of course not really desirable on a machine accessible by others on the Internet, but as I mentioned above, this setup is not meant for such use.)

You can still tweak the PHP settings, if you wish, by clicking the "Config" button in the Apache line of the XAMPP Control Panel, and then selecting "PHP (php.ini)" in the pop-up menu.

Where to Put Your Website Files

If you have accepted the default location for XAMPP (that is, "c:\xampp"), you can place your website files in "c:\xampp\htdocs\". After installation, there is a lot of rubbish in that folder, all of which you can delete. The aforesaid "rubbish" basically function as the XAMPP welcome page with advertising links to the Bitnami installers. I tend to simply delete everything in that directory before putting my own files there. If you have installed the Webalizer web statistics module, you should probably avoid deleting the "webalizer" folder that is there. (Note that even if you did not choose to install Webalizer, there will still be a placeholder "webalizer" directory, but it will be empty and you can freely remove it.)

To delete the files, just open that folder, select the files you don't want, right click your mouse button, and hit "Delete". (You can open that folder by clicking the Windows start menu button, typing "c:\xampp\htdocs\" and hitting ENTER.)

Any HTML or PHP file you want to "publish" on your web server should be copied into that same folder (ie, "c:\xampp\htdocs\"). In fact, since everything is on your local computer, you can simply create, edit and save files directly in that directory if you like. So, for example, if you put a file called "whatever.html" in that folder, you can access it as "http://localhost/whatever.html" in your web browser.

If you have a Perl script that you want to run, put it into "c:\xampp\cgi-bin" instead. Notice I said "c:\xampp\cgi-bin" and not "c:\xampp\htdocs\cgi-bin". For example, if you put a Perl script called "" in "c:\xampp\cgi-bin\", it can be referenced with a URL of "http://localhost/cgi-bin/".

As implied earlier, you can access the website on your server by typing "http://localhost/" into your web browser. Alternatively, you can also use "". Both "localhost" and "" refer to your own computer.

Testing Your Web Server

After you have deleted the default XAMPP files in the htdocs directory, you can test your server installation by creating a file with the following content and saving it as "index.php" in that folder.


Then type "http://localhost/" in your browser. You should see a page of information (one that is probably more useful and informative than the XAMPP default page that you deleted earlier) about your server installation, including the versions of the Apache, PHP, MySQL and how they are configured.

Note: if you were reluctant to delete the default XAMPP files, but still want this information, save the file as some other name, eg, "test.php". Then access it in your browser as "http://localhost/test.php".


That's it. You can now write and test your web programs on your local installation of Apache without worrying about those programs affecting visitors at your real website.

Copyright © 2016-2018 Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

New Articles

Popular Articles

How to Link to This Page

It will appear on your page as:

How to Install and Configure Apache, PHP, Perl and MySQL on Windows the Easy Way (with XAMPP)

Link to Us
No Spam Policy
Privacy Policy
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Web Hosting
Perl / CGI
.htaccess / Apache


Free webmasters and programmers resources, scripts and tutorials Free How-To Guides
Site Design Tips at
Find this site useful?
Please link to us.