Okay! So, you want to install a Apache web server on your Windows PC. Good for you!
A local web server allows you to play around with WordPress, themes and plugins without the world following every step you take. And no matter how experienced you are with WordPress, you will always need a place to experiment.
Besides that, a local web server it is also a great tool for creating your own or client websites. Locally, on your own PC. Prepare the site offline on your machine and upload it to the web you are ready to show your work to the world.
In this post I will show you how you can install a XAMPP web server on your Windows PC. It takes only five easy steps. And XAMPP delivers everything you need to install and use WordPress locally.
What do we need?
- Apache – the actual web server
- PHP – for executing PHP scripts
- MySQL – to store content and configuration data
- phpMyAdmin – a web interface for managing MySQL
Strictly speaking, we do not need phpMyAdmin. It provides a graphical user interface – in your browser – for managing MySQL.
However, without phpMyAdmin you have to do all the necessary database work from the command line. With Windows that means turning to the DOS prompt.
Let us keep it simple and use phpMyAdmin instead.
All-in-One Web Servers
There is no need to download and install the required web server components separately.
Fortunately, there are some great all-in one web server packages available for training and testing purposes. These packages are free to download and easy to install. Personally, I prefer XAMPP, which is available for Windows, Mac and Linux.
Alternatives for Windows are EasyPHP and WampServer. Please note that the components included in these alternatives may vary. EasyPHP, for example, does not include phpMyAdmin in the core package – you will have to install an additional module.
Another all-in-one option for Mac users is MAMP. Linux user can either install the Linux version of XAMPP, or download the individual components from the repository of their Linux distribution. Instructions for Ubuntu and Debian users are available on HostingCaddie.
The steps below show you how to install XAMPP on Windows – I am using Windows 7. Let’s get that local web server up and running.
Step 1 – Downloading XAMPP
First you have to grab acopy of XAMPP for Windows. Direct your browser to the XAMPP Windows page.
Since November last year, the version number of XAMPP refers to the PHP version included. Version 1.8.3 and 5.5.x both come with PHP 5.5. WordPress requires PHP 5.2.4, although version 5.4 or greater is recommended. Hence, 1.8.3 and up are all safe bets.
First you have to decide between the full version and a portable version. The portable version has everything we need, but before you can use the web server, you have to start Apache and MySQL manually.
A benefit of the full version is that you can run Apache and MySQL as a service. Because of that, both start automatically when you start Windows. The disadvantage is that these services need resources. So it is up to you. What are the specs of your PC? Are you going to use the web server a lot or only now and then?
Next, you can choose between an .exe, .zip or .7z archive. The advantage of the zip and 7z files is that uninstalling is a matter of deleting the xampp folder. Uninstalling the exe-version requires you to remove the software through the Windows Control Panel.
Since I usually work on Linux, I choose the portable 7z version. It is also the most compact version.
Step 2 – Installing XAMPP
Once the download has arrived on your PC, you can unpack it. You find a xampp folder inside the zip or 7z archive.
Move or copy that xampp folder to the top-level directory of the hard disk. It does not matter whether it is C:\ or whatever letter what letter has been assigned to the hard disk. Here I will continue using C:\. So, XAMPP should now be located at C:\xampp. When it is, you have completed the installation. Well done.
Step 3 – Starting XAMPP
Look inside your xampp folder for the file xampp-control.exe and double click it. The XAMPP Control Panel appears. Now click the [Start]-buttons at the right next to Apache and MySQL. When both are displayed on a green background, you know that the web server is running. Congratulations! You are now a webmaster.
The checkboxes at the left hand side of Apache and MySQL are grayed out here. That is because I have downloaded the portable version. Hence, I am not able to run Apache and MySQL as a service.
When you have downloaded the full version, you can. Running Apache and MySQL as a service will start and stop both together with Windows, and you can control these from Administrative Tools >> Services – just look for Apache and MySQL in the Service listing.
Step 4 – Stopping XAMPP
Stopping XAMPP is as easy as starting it. In the XAMPP Control Panel, click the [Stop]-buttons next to Apache and MySQL. Both buttons revert to [Start]-buttons. That is it.
Double clicking the icon of the XAMPP Control Panel in the Windows Taskbar will hide the window completely. Double clicking on the XAMPP icon in the Windows system tray, will toggle the XAMPP window.
Another way of starting and stopping XAMP is with the xampp_start.exe and xampp_stop.exe files in the XAMPP folder. When that is more convenient to you, consider creating shortcuts to those files and add these to your Start Menu or Taskbar.
Step 5 – Testing XAMPP
The green backgrounds in the XAMPP control panel indicate that our web server is running, but is it really? Let’s conduct a little experiment to test our web server. We need a small PHP script for that.
Launch a plain text editor like Windows Notepad, or better install the free Notepad++. Notepad++ offers syntax highlighting and does not have the habit to append .txt to file names with the PHP extension like Windows Notepad – you can prevent that by putting the file name between double quotes.
You should definitely not use a word processor like Microsoft Word or LibreOffice Writer for code! When you enjoy coding, have a look at Sublime Text.
Create a new document with the text editor and enter the following code:
<?php phpinfo(); ?>
Save the file as info.php. The info.php script contains the phpinfo() function, which informs you about all relevant information of your web environment.
Copy or move the file to the htdocs folder within the XAMPP folder. The htdocs folder is the web root folder comparable to the public_html or www folder with you hosting company.
When you have followed the instructions above you have to put the info.php file in C:\xampp\htdocs. Check that your web server is running.
Type the following URL in the address bar of your browser: http://localhost/info.php and hit the enter key – or click the previous link.
When everything is okay, the page within your browser should look something like this:
Please note that XAMPP is great for testing and training, but is not intended for production sites. For the sake of simplicity, several security measures have been omitted. That is not a problem on our local web server, but it might become a problem when deployed on the web.
And since the info.php script produces a detailed report of the web server, you should always delete it as soon as possible on live sites.
Of course, there is a lot more to explain about Apache, MySQL, PHP and phpMyAdmin. But for our purpose – running WordPress locally on our own PC – this should be sufficient.