XAMPP
Complete guide to installing and using Apache and MySQL with XAMPP
What is XAMPP?
XAMPP is a free software package that contains Apache, MySQL, PHP and Perl. It's an all-in-one solution for developing web applications locally.
Installing XAMPP
Step 1: Download XAMPP
Visit the official Apache Friends page and download the version compatible with your operating system.
Step 2: Run the installer
Run the downloaded file and follow the installation wizard. Make sure to install it in a path without spaces.
Step 3: Select components
During installation, select Apache and MySQL as the main components.
Step 4: Finish installation
Complete the installation and launch the XAMPP Control Panel.
Apache Configuration
Start Apache
- Open the XAMPP Control Panel
- Click "Start" next to Apache
- The indicator should turn green
- Verify by going to
http://localhostin your browser
Basic configuration
Apache's main configuration file is located at:
xampp/apache/conf/httpd.conf
Important directories
- Document Root:
xampp/htdocs/- This is where you place your PHP files - Logs:
xampp/apache/logs/- Log files
MySQL Configuration
Start MySQL
- In the Control Panel, click "Start" next to MySQL
- The indicator should turn green
- Go to phpMyAdmin in
http://localhost/phpmyadmin
Security configuration
- The root user initially has no password
- Recommended: Set a password from phpMyAdmin
- You can change the configuration in
xampp/mysql/bin/my.ini
Connecting from PHP
MySQLi connection example:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "mi_base_datos";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Conexión fallida: " . $conn->connect_error);
}
echo "Conectado exitosamente";
?>
Testing the installation
Create a test file
Create a file info.php in xampp/htdocs/ with the following content:
<?php
phpinfo();
?>
Go to http://localhost/info.php to view the PHP information.
Common troubleshooting
Port already in use
If Apache doesn't start, it may be because port 80 is already in use. Change the port in the Apache configuration.
Access denied
On Windows, run XAMPP as administrator to avoid permission issues.
MySQL won't start
Check that no other MySQL service is running. You can change the port in the configuration.