Set Up a Local Server
If you’re a web developer or just starting with PHP and MySQL, setting up a local server is essential for testing and development. XAMPP is a free, easy-to-use software that allows you to run a local web server on your computer. This guide will walk you through the step-by-step process of installing and configuring XAMPP for your development needs.
Step 1: Download XAMPP
1️⃣ Visit the official XAMPP website: apachefriends.org
2️⃣ Choose the XAMPP version compatible with your operating system (Windows, macOS, or Linux).
3️⃣ Click Download and wait for the installation file to be saved.
Step 2: Install XAMPP
1️⃣ Open the downloaded XAMPP installer (.exe for Windows, .dmg for macOS).
2️⃣ If prompted, click Yes to allow installation.
3️⃣ Select the components required (Apache, MySQL, PHP, and phpMyAdmin should be checked).
4️⃣ Choose the installation directory (default: C:\xampp for Windows).
5️⃣ Click Next and wait for the installation to complete.
6️⃣ Click Finish to launch the XAMPP Control Panel.
Step 3: Start Apache and MySQL
1️⃣ Open the XAMPP Control Panel from the Start menu or desktop shortcut.
2️⃣ Click Start next to Apache (this starts the local web server).
3️⃣ Click Start next to MySQL (this starts the database server).
4️⃣ If both services turn green, your local server is running successfully!
Step 4: Test Your Local Server
1️⃣ Open your web browser.
2️⃣ Type http://localhost in the address bar and press Enter.
3️⃣ If the XAMPP Dashboard appears, your server is set up correctly!
Step 5: Create a PHP Project
1️⃣ Navigate to the XAMPP installation folder:
- Windows:
C:\xampp\htdocs\
- macOS:
/Applications/XAMPP/htdocs/
2️⃣ Create a new folder (e.g.,myproject
).
3️⃣ Inside the folder, create a file named index.php.
4️⃣ Open the file in a code editor and add the following code:
<?php
echo "Hello, XAMPP is working!";
?>
5️⃣ Save the file and open your browser.
6️⃣ Visit http://localhost/myproject – You should see “Hello, XAMPP is working!” displayed.
Step 6: Access phpMyAdmin (Database Management)
1️⃣ Open your browser and go to http://localhost/phpmyadmin.
2️⃣ This is where you can create and manage MySQL databases.
3️⃣ Click on Databases, enter a name, and click Create to add a new database.
Step 7: Stop the Server When Done
1️⃣ Open the XAMPP Control Panel.
2️⃣ Click Stop next to Apache and MySQL.
3️⃣ Click Exit if you want to close XAMPP completely.
📌 Video Tutorial: Watch here