1. What is XAMPP?
XAMPP is an open-source, cross-platform web server package. Developed and updated by Apache Friends, it's completely free to download and use. The main components include the Apache HTTP Server and the MariaDB database. It also includes interpreters for programming languages like Perl and PHP.
XAMPP is compatible with Linux, Windows, and Mac operating systems, making it an incredibly flexible server solution. It also supports both LAMP and WAMP.
XAMPP is an acronym, with the key components represented by the following initials:
- X stands for cross-platform.
- A is for Apache server.
- M is for MariaDB database (or MySQL).
- P is for PHP.
- P is for PERL.
2. Opening PHP Files in XAMPP
Opening and running a PHP file in XAMPP is a breeze. All you need is a working copy of XAMPP and a PHP file. Then, follow the step-by-step instructions below:
Step 1:
Firstly, download XAMPP. You'll need a version of XAMPP compatible with your computer's operating system. Opt for the latest version of the program.
Step 2:
Next, install XAMPP on your computer. The most common approach is to install the program on drive C, although some users may opt for drive D or other non-system partitions.
To install XAMPP, right-click on the downloaded installer file. Click the Run button to initiate the installation process. Follow the setup wizard to complete the process. In the Components section, you can choose to skip some components if you're sure you won't need them. However, it's recommended to keep everything and install the full version.
The default location is C:\xampp. Users can change it if they wish, but it's not advisable.
Step 3:
In this step, you'll create a project folder to store the PHP files you want to run in XAMPP. To do that, navigate to the XAMPP folder and open the htdocs folder. There, create a new folder and name it according to the project you will paste into it. Alternatively, you can name it NewProject, Project 1, or any other desired name.
Step 4:
. In the next line, open the header with
. Close the header in the next line with .
in the following line. Press Enter a few times and hit TAB to indent. Type
. Below that line, you input . Press Ctrl + S to save the changes in the file. Finally, your file may look like the example below:
Step 5:
Now, open the file in XAMPP, and here's how to do it:
- Open XAMPP. You can launch the program through the icon in the system tray or search in the Start menu if you're using a Windows computer.
- In the Control Panel window of the program, click the Start button next to Apache to launch the Apache server. The Apache label will turn green, and you'll see a message in the log below, indicating that the server is running.
- Now, open your web browser and type localhost in the address bar.
- Click on the localhost - Welcome to XAMPP option just below the address bar.
- You will be redirected to localhost/dashboard. Replace the dashboard part with the name of the folder storing your PHP files, for example, localhost/NewProject.
- In the list of files displayed in the folder, click on the PHP file.
- If everything is fine, your PHP file will open in the browser.
As an open-source and free solution, XAMPP is a common choice for web developers and testers working on a tight budget. Additionally, XAMPP is a widely trusted web server creation tool. Its cross-platform support is one of the factors contributing to its popularity.