In this article · 8 sections
Editing PHP files directly on a live server is risky: one mistake and customers see an error. XAMPP localhost lets you run Apache, PHP and MySQL on your own computer, so you can build and test safely, then upload when ready.
Install XAMPP
- Download XAMPP from the official Apache Friends website (choose a PHP 8.x version)
- Install to the default
C:\xamppfolder - Open the XAMPP Control Panel
- Click Start next to Apache and MySQL; both should turn green
Your first page
- Create a folder:
C:\xampp\htdocs\mysite - Add
index.php:
<?php echo "Hello from localhost! PHP " . PHP_VERSION; ?>
- Open
http://localhost/mysite/in your browser
phpMyAdmin
Open http://localhost/phpmyadmin to create databases, tables and run SQL. Default user is root with no password on a fresh install (fine for local use only). See MySQL basics.
Copy a live site to localhost
- Download the site files from hosting (File Manager zip or FTP)
- Export the database from hosting phpMyAdmin
- Put the files in
htdocs/yoursite - Create a local database and import the SQL file
- Update the database credentials in the config file (e.g.
localhost,root, empty password) - If the site uses absolute URLs or
.htaccessrewrites, adjust the base URL; enablemod_rewrite(on by default in XAMPP)
Common problems
| Problem | Fix |
|---|---|
| Apache won't start: port 80 in use | Close Skype/IIS/other servers, or change Apache's port to 8080 in httpd.conf and use localhost:8080 |
| MySQL won't start: port 3306 in use | Another MySQL is running; stop it or change the port |
| Blank white page | Turn on errors: ini_set('display_errors', 1); error_reporting(E_ALL);. See debugging PHP errors |
| Import fails: file too large | Increase upload_max_filesize and post_max_size in php.ini, then restart Apache |
| Special characters broken | Use utf8mb4 for the database and connection |
Alternatives
Laragon (fast, Windows), MAMP (Mac), Docker (advanced), or PHP's built-in server: php -S localhost:8000.
When you're ready
Upload to your hosting: see deploy a PHP website to Hostinger. Keep code in Git: see Git basics.
FAQs
Is XAMPP safe?
It's for local development. Don't expose it to the internet.
Can I run WordPress on XAMPP?
Yes. Create a database, put WordPress in htdocs, and run the installer.
Was this article helpful?
Your answer helps us improve our guides