Skip to content

Techeons

Imagine | Explore | Innovate

Menu
  • Home
Menu

How to setup a PHP-MySQL App on Apache server on Windows – using XAMPP Server

Posted on September 1, 2024

XAMPP is a free and open-source web development stack that allows you to create a local web server on your computer for testing and development purposes. It provides a simple and easy-to-use solution for setting up a web server, database, and other essential tools for building and testing web applications.

Key Components:

  • X: Cross-platform (works on Windows, macOS, and Linux)
  • A: Apache (web server)
  • M: MySQL (database management system)
  • P: PHP (programming language)
  • P: Perl (programming language)

Features:

  • Easy installation and setup
  • Integrated Apache, MySQL, PHP, and Perl
  • Supports multiple databases (e.g., MySQL, MariaDB, PostgreSQL)
  • Includes phpMyAdmin for database management
  • Allows for easy switching between PHP versions
  • Portable and can be run from a USB drive

Use Cases:

  • Local web development and testing
  • Prototyping and proof-of-concept development
  • Development of dynamic web applications
  • Testing and debugging of web applications

1) Install XAMPP Server

XAMPP Server Download: https://www.apachefriends.org/download.html

2) Clone or download the app to your Webserver location

C:\xampp\htdocs\<your_app>\

Start the XAMPP Server.

3) Apache Configuration for Virtual Hosts:

On Windows: Open the Apache configuration file httpd-vhosts.conf located at:

C:\xampp\apache\conf\extra\httpd-vhosts.conf

Add your virtual host configuration.
Remember to change your_app with the name of your app and yourapp.local with your desired domain name.
Here’s an example configuration:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/your_app"
    ServerName yourapp.local
    <Directory "C:/xampp/htdocs/your_app">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/your_app_error.log"
    CustomLog "logs/your_app_access.log" common
</VirtualHost>

Edit the Main Apache Configuration File:

  • On Windows:
    • Open the Apache configuration file httpd.conf located at C:\xampp\apache\conf\httpd.conf.
    • Ensure the following line is uncommented (remove the # at the beginning if present):
    Include conf/extra/httpd-vhosts.conf

Restart Apache: Go to the XAMPP Control Panel and click “Stop” and then “Start” for Apache

4) Setup the Host file entry

To make the virtual host work on your local machine, you need to map your custom domain to localhost in your hosts file.

Edit the hosts File:

  • On Windows:
    • Open Notepad as an Administrator (right-click on Notepad and select “Run as administrator”).
    • Open the file C:\Windows\System32\drivers\etc\hosts.
  • Add the following line:
127.0.0.1 yourapp.local

Save the file and close Notepad.

5) Setup the App DB in MySQL

  • Access phpMyAdmin:
    • Open a web browser and go to http://localhost/phpmyadmin.
  • Create a Database:
    • Click on the “Databases” tab.
    • Enter a name for your database and click “Create.”
  • Import the Database (your_app.sql):
    • Select the database you just created.
    • Click on the “Import” tab.
    • Choose the SQL file and click “Go.”

6) Verify Configuration

  • Access Your Local Application:
    • Open a web browser and navigate to http://yourapp.local.
    • You should see your application if everything is set up correctly.
    • Note that this domain will resolve only on your local machine because of the host file entry.
  • Check for Errors:
    • If you encounter issues, check the Apache error log for clues.
    • Look in C:\xampp\apache\logs\error.log

Share on Social Media
x facebook pinterest linkedin tumblr reddit emailwhatsapptelegrammastodon

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • Nginx: How to increase timeout for Nginx
  • Cheat Sheet: Essential Git Commands
  • Setting a default shell in Linux
  • Setting up Composer on Linux
  • Switch easily between Python versions on a Mac using pyenv

Tags

ai alerting aws b2 backblaze certificate cheatsheet cloud commands data-science datalake devops dns docker dremio git gitlab infra jenkins kubernetes linux metabase minikube minio monitoring mount mysql nginx nodejs notebooks openssh php python scala secrets spark ssh ssl ubuntu ufw usb web dev tools windows xampp zeppelin

©2026 Techeons | Design: Newspaperly WordPress Theme