If you want to learn PHP and/or MySQL, there’s no better way to start than by installing a LAMP/WAMP/MAMP stack on your desktop computer. The difference between LAMP, WAMP, and MAMP, as you can easily see, is the first letter which denotes the operating system name: Linux, Windows, and Mac OS X respectively.
Installing a web development stack is very straight-forward and easy, especially if you utilize an installer called XAMPP. XAMPP is an Apache distribution which contains MySQL, PHP, and Perl. It can be installed on Windows, Linux, or Mac OS X. We will demonstrate how to install XAMPP on Windows. This installation is necessary to complete our PHP and MySQL tutorials.
Step 1 – Downloading the Installer
Let us will begin by downloading the installer from the apachefriends.org website. If you ever need to find that website quickly, just perform a web search for “XAMPP” and it should be the first result.
The download links are on the home page, so they are easy to find. Download the version for your operating system. We will pick Windows here, but if you are on a Mac, choose the one for OS X.
The download will begin shortly after you click the link. If you are prompted to save the file, choose a location you will easily remember, such as your desktop. You can delete this file after you’ve finished the installation.
Step 2 – Run the Installer
Browse to the location where you saved the file. Double-click the file to start the installation. You may be presented with the following display:
Due to this warning and write permission issues, we’ll install XAMPP to C:\xampp.
Click OK to acknowledge the warning and continue to the installation wizard:
For our tutorials, we do not need: FileZilla FTP Server, Mercury Mail Server, Tomcat, Perl, or Webalizer. So you can uncheck those at this point like so:
Click next. You should then get the option to change the install folder for XAMPP. Verify that it is set to C:\xampp and click next.
On the next screen you may have the option to “Learn more about Bitnami for XAMPP”. Uncheck this box and then click next. The wizard then tells you that it’s ready to install XAMPP on your computer. Click next again.
After a few moments, the installer will finish and you’ll have a fresh installation of XAMPP nearly ready to use for our MySQL and PHP tutorials. The wizard will ask if you want to start the Control Panel right away. Make sure this box is checked and click finish.
Step 3 – Introduction to XAMPP
Now that we have XAMPP installed, we need to know a little bit about its basic operation before we can get started learning PHP and MySQL. One import thing to note is that we must start Apache and MySQL from the XAMPP control panel anytime we want to use them. Without Apache running, our PHP examples won’t work and likewise for MySQL. So, in the PHP and MySQL tutorials, we’ll assume that both of these are already started. If you don’t get the same results as we do in our examples, this will be the first thing to check.
You should already have the XAMPP Control Panel open, so let’s look at the interface.
Notice that there are checkboxes down the left side under “Service”. This allows you to install each Module as a service in Windows. If you install it as a service, the module will start automatically when you boot Windows. We won’t be installing anything as a service for these tutorials, and you should only install them as a service if you plan on doing a lot of development and don’t want to start/stop these programs as needed. They will take up system resources, and it doesn’t make a lot of sense to run them if you aren’t using them regularly.
Let’s start Apache by clicking the “Start” button on the Apache row of the module list. You may immediately see a window like this:
Windows Firewall wants to know if it should allow Apache to open ports (80, 443) on your computer. Click “Allow access” here so that the web server will function properly.
Next start MySQL by clicking the “Start” button on the MySQL row of the modules list.
Again, you may get another Windows Firewall message. As before, “Allow access” should be clicked.
Now that Apache and MySQL are started, we can check that everything is working correctly by opening a browser and typing the following into the address bar and hitting .
You should see something like this:
Click English, and you’ll see a welcome page for XAMPP. You can explore the various links on the page. One that you should focus attention on at the moment, however, is the “Security” link. Due to the nature of our usage of XAMPP, we won’t be confusing the issue by worrying about security. We won’t go into setting the root password on MySQL and such. If you want to set that up, feel free to do so, but you will need to reference the documentation and other resources. Security for this development/testing environment isn’t very important. If we were going to run a mission critical web site using XAMPP, then yes we would want to secure the installation. Our development/testing environment will not allow an attacker access to our computer, however, so there is little risk in leaving it at default.
Step 4 – Preparing the Web Root
We have nearly everything ready to begin exploring MySQL and PHP. One last thing that we should do is move the existing files from the XAMPP web root out of the way, so we can add our own.
Open “My Computer” and navigate the C:\xampp\htdocs
This is the web root, and it should look something like this:
Select all of these files and folders. Once they are all selected, right click and choose “Cut”:
Navigate to C:\xampp and create a new folder called old_htdocs. Double-click this new folder and paste the files inside of it by right-clicking and choosing the “Paste” option.
Now, in your web browser of choice, navigate to http://localhost again.
You should see something similar to the following:
This is a directory listing of the c:\xampp\htdocs folder which is now empty.
You are now ready to begin the MySQL and PHP tutorials!