Introduction
If you’re learning PHP or developing web applications, you’ll need a local server to test your code. That’s where XAMPP comes in. XAMPP is a free and open-source software package that includes Apache (server), MySQL (database), PHP, and Perl, making it perfect for running PHP locally. In this guide, we’ll walk you through the steps to install XAMPP and run your first PHP script.
What is XAMPP?
XAMPP stands for:
- X – Cross-platform
- A – Apache
- M – MySQL
- P – PHP
- P – Perl
It provides a local server environment so you can run PHP code on your own machine without needing to host your project online.
Step 1: Download XAMPP
- Visit the official website: https://www.apachefriends.org
- Choose the version for your OS (Windows, Linux, Mac).
- Download the installer.
💡 Tip: Always download the latest stable version that supports your PHP version.
Step 2: Install XAMPP
- Run the downloaded installer.
- Allow permission if prompted by your system.
- Select components (Apache, MySQL, PHP are must-haves).
- Choose the install location (default:
C:\xampp
). - Click Next and install.
Step 3: Start the XAMPP Control Panel
- After installation, launch the XAMPP Control Panel.
- Start Apache and MySQL modules.
- If everything runs without error, you’re good to go!
🟢 Apache – Handles your PHP files
🟢 MySQL – Manages your database
Step 4: Test Localhost in Browser
- Open your browser.
- Type
http://localhost
in the address bar. - You should see the XAMPP welcome page.
🎉 Congratulations! XAMPP is now working on your computer.
Step 5: Create Your First PHP File
- Go to the htdocs folder inside XAMPP directory (
C:\xampp\htdocs
). - Create a folder named
testsite
. - Inside that, create a file named
index.php
. - Add this code:
<?php echo "Hello, PHP World!"; ?>
Step 6: Run Your PHP File
- In your browser, go to:
http://localhost/testsite/index.php
- You should see:
Hello, PHP World!
Now your local PHP environment is ready!
Common Issues & Solutions
Port 80 in use?
- Change Apache port from 80 to 8080 in config settings.
- Then visit
http://localhost:8080
.
MySQL not starting?
- Ensure no other MySQL service is running.
- Use Task Manager to close conflicting services.
Why Use XAMPP for PHP Development?
✅ Easy to set up
✅ Works on all OS
✅ Includes all necessary tools (Apache, PHP, MySQL)
✅ Great for learning and testing projects locally
Conclusion
Installing XAMPP is the first step toward learning PHP and web development. With XAMPP, you can build dynamic websites and test them locally before publishing them online. Whether you’re a beginner or an advanced coder, XAMPP is a must-have in your dev toolkit.