LearnContact
Lesson 519 min read

Setting Up XAMPP/WAMP/LAMP

Install a complete, beginner-friendly development stack that bundles PHP, Apache, and MySQL together, and run your first project from the htdocs folder.

Introduction

Manually installing and configuring PHP, a web server, and a database separately works, but it is a lot of moving parts for a beginner to wire together correctly. That is exactly the problem all-in-one stacks like XAMPP, WAMP, and LAMP solve: one installer, and you get PHP, a web server, and a database ready to go.

This lesson explains what these stacks are, walks through installing XAMPP step by step, shows how to start its services, and explains where to put your project files so you can view them in a browser.

What You Will Learn
  • What XAMPP, WAMP, and LAMP stand for and how they differ.
  • How to install XAMPP step by step.
  • How to start Apache and MySQL from the XAMPP Control Panel.
  • Where to place project files (the htdocs folder) and how to access them via localhost.

What Are XAMPP, WAMP, and LAMP?

XAMPP, WAMP, and LAMP are all "stacks" — bundled installers that combine Apache (web server), MySQL or MariaDB (database), and PHP into a single package, so you do not have to configure each piece by hand.

The main difference between them is platform support and exactly which components they bundle, though all three give you the same core combination needed to run PHP web applications locally.

XAMPP

Cross-platform — works on Windows, macOS, and Linux. The "X" stands for cross-platform; it bundles Apache, MySQL/MariaDB, PHP, and Perl.

WAMP

Windows-only stack: Windows, Apache, MySQL, PHP. Popular with Windows developers who do not need cross-platform support.

LAMP

The original stack, built for Linux: Linux, Apache, MySQL, PHP. Common on Linux servers and development machines.

Which One Should You Use?

If you are following along on Windows, macOS, or Linux and want one consistent tool across all of them, XAMPP is the most common recommendation for beginners. WAMP is a solid Windows-only alternative, and LAMP is typically set up directly on Linux servers rather than installed via a single GUI installer.

Installing XAMPP Step by Step

Installing XAMPP is straightforward and follows the same basic steps regardless of your operating system.

Installation Steps

  • Go to the official Apache Friends website (apachefriends.org) and download the XAMPP installer for your operating system.
  • Run the downloaded installer. On Windows, you may need to temporarily disable antivirus software if it interferes with the installation.
  • Choose which components to install — Apache, MySQL, and PHP should be checked by default; you can leave the others unchecked if you do not need them.
  • Select an installation directory (the default, typically C:\xampp on Windows, is fine for most users).
  • Finish the installer and launch the XAMPP Control Panel when prompted.

Starting Apache and MySQL

The XAMPP Control Panel is where you manage all of the bundled services. To run PHP files through a browser, you need at least Apache running; if your project uses a database, you also need MySQL running.

Starting Your Services

  • Open the XAMPP Control Panel.
  • Click "Start" next to Apache. Its status should turn green and show a port number (usually 80).
  • Click "Start" next to MySQL if your project needs a database. Its status should also turn green.
  • Open a browser and go to http://localhost — you should see the XAMPP welcome/dashboard page if Apache started correctly.
Port Conflicts

If Apache fails to start, another program (commonly Skype, IIS, or another web server) may already be using port 80. Either close that program or change Apache's port in the XAMPP configuration.

The htdocs Folder

XAMPP serves web files from a specific folder called htdocs, located inside your XAMPP installation directory (e.g. C:\xampp\htdocs on Windows). Anything you place inside htdocs becomes accessible through your browser at http://localhost/.

For example, a file saved at C:\xampp\htdocs\myproject\index.php would be reachable in a browser at http://localhost/myproject/index.php.

Save a .php file inside the htdocs folder
Start Apache from the XAMPP Control Panel
Open http://localhost/yourfile.php in a browser
Apache passes the request to PHP and returns the generated HTML

Example: Placing a Project File

Here is a minimal example: a file placed directly in htdocs and viewed through localhost.

C:\xampp\htdocs\test.php
<?php
echo "XAMPP is up and running!";
Browser address bar
http://localhost/test.php
Rendered in the Browser
XAMPP is up and running!

Common Mistakes

Avoid These Mistakes
  • Placing project files outside the htdocs folder and wondering why localhost cannot find them.
  • Forgetting to start Apache (and MySQL, if needed) before testing a page in the browser.
  • Assuming XAMPP is production-ready — it is designed for local development, not for hosting a live public website.
  • Running another web server or service on port 80 at the same time as Apache, causing a startup conflict.

Best Practices

  • Create a dedicated subfolder inside htdocs for each project instead of dropping files loose at the root.
  • Stop Apache and MySQL when you are done working, rather than leaving them running indefinitely.
  • Use XAMPP's phpMyAdmin (bundled with MySQL) to manage databases visually while learning.
  • Keep XAMPP updated so its bundled PHP version stays reasonably current.

Frequently Asked Questions

What is the difference between XAMPP, WAMP, and LAMP?

They all bundle Apache, a database (MySQL/MariaDB), and PHP. XAMPP is cross-platform, WAMP is Windows-only, and LAMP is the original Linux-based stack.

Where do I put my PHP project files?

Inside the htdocs folder within your XAMPP installation directory. Files placed there become accessible through your browser at http://localhost/.

Why is my Apache server not starting?

Most commonly another program is already using port 80 (such as Skype or IIS on Windows). Close the conflicting program or reconfigure Apache to use a different port.

Can I use XAMPP to host a real, public website?

It is not recommended. XAMPP is designed for local development and testing; production sites should use a properly configured, secured server environment.

Do I need to start MySQL if my project does not use a database?

No. If your PHP files do not connect to a database, you only need Apache running to view them in a browser.

Key Takeaways

  • XAMPP, WAMP, and LAMP all bundle Apache, MySQL/MariaDB, and PHP into one installer.
  • XAMPP is cross-platform, WAMP is Windows-only, and LAMP is the classic Linux stack.
  • The XAMPP Control Panel is used to start and stop Apache and MySQL.
  • Project files must be placed inside the htdocs folder to be accessible via http://localhost/.

Summary

All-in-one stacks like XAMPP remove the friction of configuring Apache, MySQL, and PHP separately, letting you focus on writing code instead of wiring up infrastructure. Once installed, starting Apache and dropping files into htdocs is all it takes to see your PHP pages live at localhost.

In this lesson, you learned what these stacks are, installed XAMPP, started its services, and placed a file in htdocs to view in a browser. Next, you will write and run your very first real PHP program.

Lesson 5 Completed
  • You understand what XAMPP, WAMP, and LAMP each provide.
  • You can install XAMPP and start Apache and MySQL from its Control Panel.
  • You know that project files belong in the htdocs folder.
  • You are ready to write your first PHP program.
Next Lesson →

Your First PHP Program