How to Install and Set Up XAMPP on Windows: A Beginner’s Step-by-Step Guide
In this guide, I will walk you through how to download, install, configure, and test XAMPP on Windows. By the end of this tutorial, you should be able to run your first local PHP project and begin experimenting with MySQL-compatible databases.
· 4 min read
Introduction
If you are interested in learning web development, building applications with PHP, or working with databases, setting up a local development environment is one of the first steps you should take.
One of the easiest tools for beginners is XAMPP. It allows you to run a web server and database on your Windows computer without needing to purchase web hosting or immediately deploy your projects to the internet.
In this guide, I will walk you through how to download, install, configure, and test XAMPP on Windows. By the end of this tutorial, you should be able to run your first local PHP project and begin experimenting with MySQL-compatible databases.
- What Is XAMPP? XAMPP is a free, cross-platform web development package that provides the essential tools needed to run many PHP-based web applications locally.
The name represents its main components: X — Cross-platform, meaning it is available for different operating systems. A — Apache, the web server that serves your website. M — MariaDB, the database server used to store application data. P — PHP, the programming language commonly used for server-side web development. P — Perl, a programming language included in the distribution.
Although people commonly refer to the database as MySQL, modern XAMPP distributions generally include MariaDB, which is compatible with many MySQL tools and workflows.
Why should you use XAMPP? XAMPP is useful because it allows you to: i. Develop and test websites without an internet connection, once the software is installed. ii. Learn PHP and database development. iii. Run many PHP content management systems and web applications locally. iv. Test database queries and manage databases using phpMyAdmin. v. Build prototypes before deploying them to a live server. vi. Experiment with frameworks such as Laravel, subject to their specific PHP and extension requirements.
XAMPP is primarily intended for local development and testing, not as a secure, production-ready public web server.
- Requirements Before Installation Before installing XAMPP, ensure that you have: i. A Windows computer. ii. Administrator access if Windows requests permission during installation. iii. Sufficient free disk space for the installation and your projects. iv. A stable internet connection to download the installer. v. A modern web browser, such as Chrome, Edge, or Firefox.
You should also check which PHP version your intended project requires. This is especially important when working with Laravel or an existing PHP application.
- Download XAMPP for Windows The safest place to download XAMPP is its official website.
Official download page: https://www.apachefriends.org/
Follow these steps: Open the official Apache Friends website.
Navigate to the XAMPP download section.
Select the Windows version.
Choose a release that is compatible with your intended project.
Download the Windows installer.
Avoid downloading installers from unknown websites, as they may contain unwanted or malicious software.
Important: If you are installing XAMPP for an existing project, check the project's PHP version requirements before choosing a release.
- Install XAMPP on Windows
Once the download is complete, locate the installer in your Downloads folder.
Step 1: Run the installer
Double-click the downloaded XAMPP installer. If Windows displays a User Account Control prompt, verify that the installer came from the official source before allowing it to run.
If you receive a warning about antivirus software or User Account Control, read it carefully and follow the official installation guidance rather than disabling security protections unnecessarily.
Step 2: Select the components
The installer may allow you to choose which components to install.
For a typical PHP development environment, the following are useful:
Apache
MySQL/MariaDB
PHP
phpMyAdmin
You can leave other components unchecked if you do not need them.
Step 3: Choose the installation directory
For a straightforward setup, use:
C:\xampp
This is a convenient location for local development. Avoid installing XAMPP inside a protected Windows directory such as C:\Program Files, where permissions may create additional complications.
Step 4: Complete the installation
Follow the installer prompts and wait for the installation to finish.
If asked whether to launch the XAMPP Control Panel, select the option to open it.
You should now have a local development environment ready for configuration.
- Start Apache and MySQL
The XAMPP Control Panel lets you start and stop the services required by your projects.
Step 1: Open the XAMPP Control Panel
If it is not already open, search for XAMPP Control Panel in the Windows Start menu.
For troubleshooting or service-management operations, running the Control Panel as an administrator may be necessary.
Step 2: Start Apache
Locate Apache and click Start.
If it starts successfully, the panel will indicate that the service is running.
Apache is responsible for serving your local websites and PHP applications.
Step 3: Start MySQL
Locate MySQL in the Control Panel and click Start.
In XAMPP, this starts the bundled MariaDB database server, which is commonly accessed through MySQL-compatible tools.
If both services start successfully, you can proceed to testing your installation.
- Test Your XAMPP Installation
Open your browser and enter:
If XAMPP is running correctly, you should see the local XAMPP dashboard or welcome page, depending on your installed version and configuration.
You can also try:
Both addresses normally point to your own computer.
What if the page does not open?
Check that Apache is running in the XAMPP Control Panel. Also confirm that you entered the address correctly and that another application is not using Apache's configured port.
Do not proceed to project development until you can access the local server successfully.
- Create Your First PHP Project
Now that XAMPP is running, let's create a simple PHP project.
Step 1: Open the htdocs directory
Navigate to:
C:\xampp\htdocs
The htdocs directory is Apache's default document root in a standard XAMPP installation. Files placed here can be served through your local web server.
Step 2: Create a project folder
Inside htdocs, create a folder named:
my-first-project
Your folder structure should look like this:
C:\xampp\htdocs
└── my-first-project
└── index.php
Step 3: Create the index.php file
Open a code editor such as Visual Studio Code or Notepad and create a file named index.php inside the new folder.
Add the following code:
Save the file.
Step 4: Open your project in the browser
Enter this address:
http://localhost/my-first-project/
If everything is configured correctly, your browser should display the welcome message.
Congratulations! You have successfully created and run your first local PHP project.
- Access phpMyAdmin and Create a Database
Most dynamic websites and applications need a database to store information such as user accounts, products, transactions, and application settings.
XAMPP includes phpMyAdmin, a browser-based interface for managing your MariaDB database.
Step 1: Open phpMyAdmin
With Apache and MySQL running, visit:
Step 2: Create a database
Depending on your phpMyAdmin version, you can create a database by selecting the Databases tab or using the database creation interface.
For this example, enter:
my_first_database
Choose an appropriate collation if needed, then create the database.
You can now use phpMyAdmin to create tables, run SQL queries, import database files, and inspect records.
Security note: Do not expose phpMyAdmin or an unsecured database server to the public internet. For local development, keep access restricted to your computer and configure proper database credentials for applications.
- Common XAMPP Problems and How to Fix Them
Even when the installation is correct, you may occasionally encounter errors. Here are some common problems and troubleshooting steps.
Problem 1: Apache will not start
One possible cause is a port conflict. Another application may already be using Apache's default HTTP port, usually port 80, or its configured HTTPS port, usually port 443.
What to do:
Open the XAMPP Control Panel.
Review the Apache error messages and logs.
Check whether another service, such as IIS or another web server, is using the same port.
Stop the conflicting service if it is safe and appropriate to do so, or configure Apache to use an available port.
Restart Apache and test the correct local URL.
If you change Apache's port to 8080, for example, you would normally access the server using http://localhost:8080/.
Do not change ports randomly; first identify the actual conflict.
Problem 2: MySQL will not start
Possible causes include a port conflict, an existing database service, or a database configuration or data-directory problem.
What to do:
Read the MySQL/MariaDB error log in the XAMPP Control Panel.
Check whether another database server is already running.
Confirm whether the configured database port is available.
Investigate any reported configuration or data-directory errors.
Do not delete database files or replace the database's data directory as an initial troubleshooting step. Those actions can cause permanent data loss. Back up your data before attempting recovery.
Problem 3: The browser displays a 404 error
A 404 error generally means that the requested path or file cannot be found.
What to do:
Confirm that your project is inside C:\xampp\htdocs.
Check the folder and filename spelling.
Confirm that index.php exists.
Verify that the URL matches the project folder name.
For example, a project located at C:\xampp\htdocs\my-first-project should normally be available at http://localhost/my-first-project/.
Problem 4: PHP code appears as plain text or does not execute
PHP code should be processed by the PHP interpreter through a configured web server.
Make sure that you are opening the project through http://localhost/... rather than opening the PHP file directly from your computer using a file:/// address.
Also verify that Apache and PHP are configured correctly in your XAMPP installation.
Problem 5: Port 3306 is already in use
Port 3306 is the common default port for MySQL-compatible database servers.
If another database service is already using it, XAMPP's database server may fail to start.
Check which application owns the port before changing configuration. If you decide to use another port, update the relevant database and application settings consistently.
- Using XAMPP for Laravel Development
If your goal is to build modern PHP applications with Laravel, XAMPP can provide a useful local environment. However, Laravel has additional requirements beyond simply starting Apache and MariaDB.
Before installing Laravel, check the requirements for the specific Laravel version you intend to use, including:
A compatible PHP version.
Required PHP extensions.
Composer, the PHP dependency manager.
A compatible MySQL/MariaDB database.
Node.js and a package manager if your project requires compiling frontend assets with Vite.
Environment configuration, storage permissions, and database credentials.
You can check the PHP version available in your terminal with:
php -v
You can check whether Composer is installed with:
composer --version
If Windows reports that either command is not recognized, the relevant executable may not be installed or may not be included in your system's PATH.
Also, if you have multiple PHP installations, your terminal may use a different PHP version from the one used by Apache. Check both environments when troubleshooting.
For Laravel projects, use the framework's official installation documentation to verify version-specific requirements: https://laravel.com/docs
- Best Practices When Using XAMPP
To make your development environment more reliable, follow these recommendations:
Keep XAMPP updated. Use a supported release compatible with your project and apply security updates appropriately.
Protect your databases. Back up important data before changing database settings or attempting recovery.
Use version control. Git helps you track code changes and recover earlier versions.
Keep credentials private. Never publish database passwords, API keys, or application secrets in public repositories.
Use realistic project structure. Organize your source code, assets, configuration, and documentation instead of putting everything into a single file.
Avoid public exposure. Do not treat a default XAMPP installation as a production hosting environment.
Test before deployment. Verify your application, database migrations, permissions, and security configuration before publishing it online.
Conclusion
Setting up XAMPP on Windows is a practical first step toward learning PHP, understanding databases, and building web applications locally.
Once Apache and MySQL are running, you can test PHP projects, create databases with phpMyAdmin, and begin developing more advanced applications.
If you are learning software development, my recommendation is to start with a small PHP project, understand how the application communicates with a database, and then progress to a framework such as Laravel.
The goal is not simply to install a tool. It is to establish a reliable development environment that helps you learn, experiment, build, and solve real-world problems.
Keep learning, keep building, and keep improving.
— Ifeanyi Osiaku