Skip to main content
XAMPP Notes — Part 2 of 3
Page 1
Prepared By: Jaydeep Kale
XAMPP
Part 2 of 3: MariaDB, htdocs, First PHP Program, localhost, phpMyAdmin,
Directory Structure & Config Files
XAMPP Notes — Part 2 of 3
Page 2
Prepared By: Jaydeep Kale
Contents of Part 2
• 7. MariaDB (MySQL)
• 8. Understanding the htdocs Folder
• 9. Running Your First PHP Program
• 10. localhost
• 11. phpMyAdmin
• 12. XAMPP Directory Structure
• 13. Configuration Files
XAMPP Notes — Part 2 of 3
Page 3
Prepared By: Jaydeep Kale
7. MariaDB (MySQL)
What is MariaDB/MySQL?
MariaDB is a relational database management system (RDBMS) bundled with XAMPP to store, organize, and
manage data used by websites and applications — such as user accounts, product catalogs, or blog posts. It is a
community-developed, fully compatible fork of MySQL, meaning almost all MySQL commands, syntax, and
tools work identically with MariaDB. Data is stored in structured tables made up of rows and columns, and is
accessed using SQL (Structured Query Language).
Starting the Database Server
1. Open the XAMPP Control Panel.
2. Locate the 'MySQL' row.
3. Click the 'Start' button next to it.
4. Wait a few seconds; the row turns green and displays 'Running' along with its PID and Port once the
database server has started successfully.
5. The database server is now ready to accept connections from PHP scripts or from phpMyAdmin.
Default Port (3306)
MariaDB/MySQL listens for incoming connections on Port 3306 by default. Any application connecting to the
database (such as a PHP script or phpMyAdmin) needs to know this port, though most tools assume 3306
automatically unless it has been changed.
Creating Databases
A database can be created either through phpMyAdmin's graphical interface (covered in Topic 11) or directly
with SQL commands. To create a database using SQL:
CREATE DATABASE mydatabase;
To view all existing databases on the server:
SHOW DATABASES;
To start using (select) a particular database before creating tables inside it:
USE mydatabase;
XAMPP Notes — Part 2 of 3
Page 4
Prepared By: Jaydeep Kale
8. Understanding the htdocs Folder
Purpose of htdocs
The htdocs folder is Apache's default 'DocumentRoot' — meaning it is the root directory from which Apache
serves all web files. By default it is located at C:xampphtdocs on Windows. Any file or folder you place inside
htdocs becomes accessible through a browser using the localhost address.
For example, a file saved at C:xampphtdocstest.php can be opened in a browser at http://localhost/test.php.
Creating Project Folders
1. Navigate to the XAMPP installation folder (e.g., C:xampp).
2. Open the htdocs subfolder.
3. Create a new folder here and name it after your project, for example 'mywebsite' (avoid spaces and special
characters in the folder name).
4. Place all your project files — PHP, HTML, CSS, JS, images — inside this new folder.
5. Access the project in a browser using http://localhost/mywebsite/.
Folder Structure
A typical, well-organized project folder inside htdocs might look like this:
htdocs/
mywebsite/
index.php
css/
style.css
js/
script.js
images/
logo.png
includes/
db_connect.php
Keeping styles, scripts, images, and reusable PHP includes in separate subfolders makes the project easier to
maintain as it grows.
XAMPP Notes — Part 2 of 3
Page 5
Prepared By: Jaydeep Kale
9. Running Your First PHP Program
Creating a PHP File
1. Make sure Apache is running (green in the Control Panel).
2. Open the htdocs folder (e.g., C:xampphtdocs).
3. Create a new folder for your first project, for example 'firstproject'.
4. Inside that folder, create a new text file and rename it to index.php (make sure the extension is .php, not
.php.txt).
5. Open index.php in any code/text editor such as VS Code or Notepad.
Writing "Hello World"
Type the following PHP code inside index.php and save the file:
<?php
echo "Hello World";
?>
Here, <?php and ?> are the opening and closing PHP tags that tell Apache where PHP code begins and ends. The
echo statement outputs text to the browser — in this case, the words 'Hello World'.
Accessing via localhost
1. Open any web browser.
2. In the address bar, type the following URL and press Enter:
http://localhost/firstproject/
3. Apache locates index.php inside the firstproject folder automatically (since index.php is the default file
Apache looks for).
4. PHP processes the code on the server and Apache sends back the result as plain HTML.
5. The browser displays the text: Hello World
Note: If the browser instead prompts you to download the .php file rather than running it, Apache and/or PHP is
not running correctly, or the file was not saved with a .php extension.
XAMPP Notes — Part 2 of 3
Page 6
Prepared By: Jaydeep Kale
10. localhost
What is localhost?
localhost is a special hostname that always refers to 'this computer' — that is, the same machine on which the
browser is running. When you type http://localhost/ in a browser, the request never leaves your computer; it goes
directly to the Apache server running locally via XAMPP, rather than travelling over the internet to a remote
server.
127.0.0.1
127.0.0.1 is the numeric IP address that localhost points to; it is known as the 'loopback address'. Typing
http://127.0.0.1/ in the browser produces exactly the same result as typing http://localhost/, since both refer to the
same local machine.
Local Server vs Internet Server
Local Server (XAMPP) Internet/Live Server
Runs on your own computer. Runs on a remote machine hosted by a hosting provider.
Accessible only from the same computer (by default). Accessible worldwide via the internet using a domain
name.
Free — no hosting cost involved. Usually requires paid hosting and a registered domain.
Ideal for development, learning, and testing. Used to publish a finished website for real visitors.
Data is lost if the local project files are deleted. Data is stored on the provider's servers with backups.
XAMPP Notes — Part 2 of 3
Page 7
Prepared By: Jaydeep Kale
11. phpMyAdmin
Introduction
phpMyAdmin is a free, web-based administration tool bundled with XAMPP that allows you to manage
MariaDB/MySQL databases through a graphical interface in the browser, instead of typing raw SQL commands
in a terminal. It supports creating databases and tables, running queries, importing/exporting data, and managing
users and permissions.
Opening phpMyAdmin
1. Make sure both Apache and MySQL are running (green) in the XAMPP Control Panel.
2. Open a web browser.
3. Type the following address in the address bar:
http://localhost/phpmyadmin/
4. Press Enter; the phpMyAdmin dashboard loads, showing a list of existing databases on the left panel.
Creating a Database
1. In phpMyAdmin, click the 'Databases' tab at the top.
2. Under 'Create database', type a name for the new database, e.g., studentdb.
3. Choose a collation (utf8mb4_general_ci is a common, safe default for supporting multiple languages).
4. Click the 'Create' button.
5. The new database now appears in the left-hand list.
Creating Tables
1. Click on the newly created database name in the left panel to select it.
2. In the 'Create table' section, enter a table name, e.g., students, and specify the number of columns.
3. Click 'Go'.
4. On the next screen, define each column's Name, Type (e.g., INT, VARCHAR, DATE), and Length/Values
as required.
5. Mark the primary key column (commonly 'id') by ticking the 'Primary' checkbox and setting 'A_I' (Auto
Increment) if desired.
6. Click 'Save' to create the table structure.
Importing SQL Files
1. Select the target database from the left panel (or create a new one first).
2. Click the 'Import' tab at the top of the page.
XAMPP Notes — Part 2 of 3
Page 8
Prepared By: Jaydeep Kale
3. Click 'Choose File' and select the .sql file you want to import from your computer.
4. Leave the format set to 'SQL' (the default).
5. Click the 'Go' button at the bottom of the page.
6. phpMyAdmin executes all the SQL statements in the file and displays a success message, along with any
tables and data created.
XAMPP Notes — Part 2 of 3
Page 9
Prepared By: Jaydeep Kale
12. XAMPP Directory Structure
Understanding the folders inside the XAMPP installation directory (default: C:xampp) helps in locating
configuration files, project files, and logs quickly.
• apache: Contains Apache's core files, including its configuration folder (conf), binaries (bin), and log files.
This is where httpd.conf resides.
• htdocs: The web server's document root — the folder where all website/project files must be placed to be
accessible via localhost.
• mysql: Contains MariaDB/MySQL's program files, along with the 'data' subfolder where all actual database
files are physically stored.
• php: Contains the PHP interpreter/engine files, extensions, and the php.ini configuration file that controls
PHP's behavior.
• phpMyAdmin: Contains the phpMyAdmin web application's source files, which Apache serves when you
visit http://localhost/phpmyadmin/.
• tmp: A temporary folder used by PHP and MySQL to store temporary session data and cache files during
operation.
• logs: (Alongside apache/logs and mysql/data logs) Stores error and access logs that help diagnose problems
when a service fails to start or a script misbehaves.
XAMPP Notes — Part 2 of 3
Page 10
Prepared By: Jaydeep Kale
13. Configuration Files
XAMPP's behavior can be customized by editing plain-text configuration files. These can be opened directly from
the Control Panel's 'Config' button, or manually with any text editor. After editing any configuration file, the
related service must be stopped and restarted for changes to apply.
httpd.conf
Location: xampp/apache/conf/httpd.conf
This is Apache's main configuration file. It defines settings such as the Listen port, the DocumentRoot (default
project folder — htdocs), server modules to load, directory access permissions, and virtual host settings.
Beginners commonly edit this file to change Apache's default port or to enable specific Apache modules.
php.ini
Location: xampp/php/php.ini
This file controls PHP's runtime behavior. Common settings adjusted here include:
• upload_max_filesize and post_max_size — control the maximum size of files that can be uploaded through
PHP forms.
• memory_limit — the maximum amount of memory a PHP script is allowed to use.
• display_errors — whether PHP errors are shown directly in the browser (useful for development, should be
off in production).
• max_execution_time — the maximum number of seconds a script is allowed to run before PHP stops it.
• extension= lines — enable or disable specific PHP extensions such as mysqli or gd.
my.ini
Location: xampp/mysql/bin/my.ini
This is MariaDB/MySQL's configuration file. It controls settings such as the port the database listens on, the data
directory location, character set defaults, and various performance-related parameters. This file is commonly
edited when changing MySQL's default port to resolve a conflict (covered in Topic 16).