XAMPP is a free and open-source cross-platform web server solution stack package developed by Apache Friends, which mainly includes the Apache HTTP server, MariaDB database, and interpreters for scripts written in PHP and Perl programming languages. It is a simple and lightweight solution that allows you to create a local web server for testing purposes. In this comprehensive guide, we will go through the process of installing and setting up XAMPP on a Windows system.
Understanding XAMPP
Before we move ahead with the installation process, let's discuss what XAMPP is and why you should use it. XAMPP stands for:
X - Cross-platform
A - Apache HTTP Server
M – MariaDB (formerly MySQL)
P - PHP
P - Pearl
XAMPP is designed as a very easy-to-install Apache distribution that includes MariaDB, PHP, and Perl. It is useful for developers who need to test website changes as it allows them to replicate the live server environment on their local machine. The biggest advantage of using XAMPP is that it is open-source and available for various operating systems including Windows, Linux, and macOS.
Benefits of using XAMPP
Selecting XAMPP as your testing environment comes with several benefits:
It is easy to install and configure.
Cross-platform capabilities allow for compatibility with a variety of operating systems.
Provides an all-in-one package for setting up a local server.
Updating XAMPP is simple.
This software is open source and free to use.
Prerequisites
Before starting the installation process, make sure that you meet the following requirements:
Computer with Windows operating system (Windows 7 or later).
A working internet connection to download the XAMPP installer.
Basic understanding of using computers and installing software.
Downloading XAMPP
The first step to set up XAMPP is to download the installation package from their official website. Follow these steps to download XAMPP:
On the homepage, you will see different versions of XAMPP available. Choose the version that is compatible with your Windows operating system.
Click the download button for your chosen version. The file will begin downloading to your computer.
Note: As a beginner, it is recommended to download the latest version to ensure compatibility with other software.
Installing XAMPP on Windows
Once the download is complete, you can begin the installation process. Follow these steps to install XAMPP on your Windows machine:
Find the XAMPP installer file you downloaded to your computer, typically found in the "Downloads" folder.
Double-click the installer file to run it. If prompted by User Account Control, click "Yes" to allow the installation.
The XAMPP setup wizard will open. Click "Next" to proceed with the installation.
On the "Select Components" screen, you can choose which components of XAMPP you want to install. It is usually advisable to leave the default selection and click "Next".
On the "Installation Folder" screen, choose the folder where you want to install XAMPP. It is usually installed in "C:\xampp". Click "Next" to continue.
The "Bitnami for XAMPP" screen may appear, giving you the chance to install additional components such as WordPress. For now, uncheck the option if you're not interested and click "Next."
Click "Next" once again to begin the installation process.
Wait for the installation to complete. Once the "Setup Complete" screen appears, click "Finish" to close the setup wizard.
Starting and configuring XAMPP
After the installation is complete, you need to start and configure the XAMPP components. Follow these steps:
Open the XAMPP Control Panel by finding it in the Start menu or the installation folder.
When the Control Panel opens, you will see a list of services like Apache and MariaDB.
Click the "Start" button next to "Apache" and "MariaDB" to run these services. You should see the status change to "Running."
With Apache and MariaDB running, your local server is now active. This allows you to manage PHP and MySQL applications from your local device.
Testing the XAMPP installation
To make sure the installation process was successful, test your XAMPP setup using these steps:
Open a Web browser and type http://localhost or http://127.0.0.1 in the address bar, then press the "Enter" key.
If everything is working correctly, you will be redirected to the XAMPP dashboard page, indicating that the local server is working.
Troubleshooting: If the XAMPP dashboard does not appear: Make sure both Apache and MariaDB are running in the XAMPP control panel, and retry accessing the above URL in your browser.
Managing XAMPP components
In the XAMPP Control Panel, you can manage various components of the stack. Here is how to use this tool effectively:
Use the control panel to stop and start services as needed depending on your development routine.
For advanced configuration, click "Configuration" next to each component, which will open the configuration files or logs where you can customize the settings.
Monitor the “Logs” regularly to spot any potential errors or problems.
Working with your first PHP script
Now that XAMPP is installed and running, you can start creating and testing PHP scripts. Follow these steps to run your first PHP script:
Go to the XAMPP installation directory. By default, this is "C:\xampp".
In this directory, find a folder called "htdocs". This is the web root folder for Apache, where you should place your PHP scripts.
Create a new folder inside "htdocs" and give it a name, let's say "myProject".
Open a text editor (such as Notepad) and type the following PHP code:
<?php echo "Hello, World!"; ?>
Save this file as “index.php” inside the “myProject” directory.
Open your web browser and enter http://localhost/myProject in the address bar.
You will see the message "Hello, World!" in the browser, indicating that your first PHP script is working.
Accessing phpMyAdmin
phpMyAdmin is a free tool provided with XAMPP to interact with MariaDB databases. It provides a user-friendly web interface to access and manage your databases. Follow these steps to access phpMyAdmin:
Make sure Apache and MariaDB are running in the XAMPP control panel.
Open your Web browser and type http://localhost/phpmyadmin in the address bar, then press "Enter."
The phpMyAdmin interface will appear, allowing you to manage your databases.
With phpMyAdmin you can create and manage databases, execute SQL queries, and more.
Setting the password for the MySQL database
To increase security, you may want to set a password for the root user of the MySQL database. Follow these steps:
Open phpMyAdmin as mentioned earlier by going to http://localhost/phpmyadmin.
Click the "User Accounts" tab at the top of the page.
Locate the “root” account keeping “localhost” as the host and click “Edit Privileges”.
Scroll down to the "Change Password" section.
Enter the secure password you want in the Password field.
Retype the password in the confirmation field, then click "Go" to save your changes.
Once you have set the password for the MySQL root user, you will also need to update the "config.inc.php" file in the phpMyAdmin directory to ensure that it records the change:
Navigate to the phpMyAdmin directory ("C:\xampp\phpMyAdmin").
Open "config.inc.php" in a text editor.
Find the line that begins with $cfg['Servers'][$i]['password'] and set it as your new password:
Saving your changes ensures that phpMyAdmin can access the database with the new password.
Stopping XAMPP
Once you have completed your development work, you may want to shut down the local server to free up your system resources:
Open the XAMPP Control Panel.
Click the “Stop” button for each active service: Apache, MariaDB, etc.
Close the XAMPP Control Panel.
Summary
In this guide, we have explained in detail how to install and set up XAMPP on a Windows system. We also explored how to manage server components, run PHP scripts, access phpMyAdmin, and enhance security. XAMPP is a valuable tool for web developers building and testing applications locally. By following these simple instructions, you can set up your own local server environment, providing a solid foundation for your development routine.
If you find anything wrong with the article content, you can