If you want to start developing PHP websites on your Windows computer, XAMPP is one of the easiest ways to create a local PHP and MySQL development environment.
With XAMPP, you can run PHP, Apache, and MySQL locally without needing a live web server.
A web server that processes and serves your PHP pages.
A server-side programming language used to build dynamic websites.
A database server used to store application data.
A web-based interface for managing databases.
Download XAMPP for Windows from the official Apache Friends website.
After downloading it, you should have an installer similar to:
xampp-windows-x64-....exe
Run the installer to begin the setup.
During installation, keep the default components selected.
Apache : Web server
PHP: Runs PHP applications
MySQL / MariaDB: Database server
phpMyAdmin: Database management
The default installation directory is usually:
You can keep this location unless you have a specific reason to change it.
After installation, open the XAMPP Control Panel.
You will see services such as:
Click Start next to Apache and MySQL.
Open your web browser and visit:
You should see the XAMPP welcome or dashboard page. This confirms that Apache is working.
XAMPP stores website files inside:
Create a folder named:
Inside the folder, create:
index.php
<?php
echo "Hello, PHP!";
?>
You can check whether PHP is working
correctly using the phpinfo()
function.
<?php
phpinfo();
?>
phpinfo()
page accessible on a production server.
phpMyAdmin provides a graphical interface for managing MySQL/MariaDB databases.
Open phpMyAdmin and select New.
Create a database named:
Then create a table called:
| Column | Type | Purpose |
|---|---|---|
| id | INT | User ID |
| name | VARCHAR (100) | User name |
| VARCHAR (150) | Email address |
Set id as the primary key
and enable auto-increment.
Create a file named:
db.php
Add the following code:
<?php $host = "localhost"; $user = "root"; $password = ""; $database = "mywebsite"; $conn = new mysqli( $host, $user, $password, $database ); if ($conn->connect_error) { die("Database connection failed: " . $conn->connect_error); } echo "Database connected successfully."; ?> Open:
root account without a password. For production applications, create a dedicated database user with a strong password. You now have a basic local PHP + MySQL development environment.
| Purpose | URL |
|---|---|
| XAMPP Dashboard | http:// |
| Your Website | http://localhost |
| phpMyAdmin | http://localhost |
Another application may already be using a port required by Apache.
Common causes include:
Another MySQL or MariaDB service may already be running on your computer.
Check Windows Services and look for an existing MySQL or MariaDB service.
Check the following:
.php extension.C:\xampp\htdocs.http://localhost. file:///C:/xampp/htdocs/
mywebsite/index.php http://localhost/
mywebsite/index.php