🇯🇵 日本語 | 🇺🇸 English | 🇪🇸 Español | 🇵🇹 Português | 🇹🇭 ไทย | 🇨🇳 中文

[PHP for Beginners] A Complete Guide to Downloading and Installing XAMPP!

"I copied and pasted some PHP code, but when I open it in a browser, the code just shows up as text..."
"It doesn't work when I double-click it like an HTML file! Why?"

When starting to learn PHP, the first major hurdle everyone encounters is "setting up a development environment." Unlike HTML and CSS, PHP requires a special "server" environment to run on your PC.

But don't worry. This is a hurdle that anyone can easily overcome with the right steps. In this article, we will explain, step-by-step and more clearly than anywhere else, the entire process from downloading and installing the free, all-in-one development environment "XAMPP" to running your very first PHP program.

By the time you finish this article, you will have transformed your PC into a web development server, giving you the best possible start for creating dynamic websites with PHP!


1. What is XAMPP and Why Do You Need It?

Before we get to the main topic, let's briefly learn what XAMPP is.

Simply put, XAMPP is "a package that easily installs a full set of software required to run PHP." Originally, running PHP required you to individually install web server software (like Apache) and database software (like MariaDB), which was a very high hurdle for beginners. XAMPP takes care of all this tedious work for you.

If you think of website creation as cooking, XAMPP is like a "complete kitchen system with a stove, countertop, sink, and refrigerator." With this, all you need to do is prepare the ingredients (your PHP code), and you can start cooking (building your website) right away.


2. How to Download XAMPP

Alright, let's get the XAMPP installer right away.

  1. Go to the Official Website
    First, visit the official XAMPP website, "Apache Friends." There can be fake sites out there, so always make sure you download from the official source.
    https://www.apachefriends.org/index.html
  2. Choose the Version for Your OS
    When you visit the site, you'll see download buttons for Windows, Linux, and OS X (Mac). Click the one that matches your PC.

    The PHP version is important here. Unless you have a specific reason, it's fine to choose the latest stable version listed at the top (e.g., 8.2.x).
    (Image of the download buttons for Windows, indicating the latest PHP version, would go here)
  3. Wait for the Download to Complete
    After clicking the download button, the installer (an `.exe` file for Windows) will begin downloading automatically. The file size is relatively large (around 150MB), so let's wait a bit for it to finish.

3. How to Install XAMPP (Windows Version)

Once the download is complete, it's time to install. You'll see several confirmation screens, but don't worry—nothing is scary if you understand what each one means. We'll use the Windows version as an example here.

  1. Run the Installer
    Double-click the downloaded file (e.g., `xampp-windows-x64-8.2.12-0-VS16-installer.exe`) to launch the installer.
  2. Warning Screen (UAC)
    You may see a warning screen first. It says something like, "Important! Because an activated User Account Control (UAC) on your system..." This message is basically just advising you to avoid installing in `C:\Program Files` because UAC might restrict some functions. It's fine to just click "OK" and proceed.
    (Image of the UAC warning dialog would go here)
  3. Start the Setup Wizard
    When the "Setup" window appears, click "Next >" to continue.
  4. Select Components
    This screen lets you choose which software to install. There are many options, but if you're a beginner and not sure, it's perfectly fine to leave the default checked items as they are. At a minimum, confirm that "Apache," "PHP," and "MySQL" are checked, and then click "Next >".
    (Image of the component selection screen would go here)
  5. Choose Installation Folder
    Decide where to install XAMPP. Unless you have a specific reason, we strongly recommend leaving it as the default, "`C:\xampp`". This helps avoid problems related to the UAC warning from earlier. Click "Next >".
  6. Select Language
    Currently, you can only choose between English and Deutsch (German). Select "English" and click "Next >".
  7. Ready to Install
    When you see "Ready to Install," this is the final confirmation before installation. Click "Next >" to begin.
  8. Important Windows Security Alert
    During the installation, you might see an alert from Windows Defender Firewall that it has blocked some features of "Apache HTTP Server." This is a confirmation of whether to allow access from external sources. Even though you're just using it for local development, please click "Allow access" to ensure Apache works correctly.
    (Image of the firewall alert screen would go here)
  9. Installation Complete
    When you see "Completing the XAMPP Setup Wizard," the installation is done! For now, uncheck the box for "Do you want to start the Control Panel now?" and click "Finish" to close the window. We'll start it manually.

4. How to Use XAMPP: Starting the Server and Running PHP

Great job! Your "kitchen" is now set up on your PC. Finally, let's actually light the stove (start the server) and run our first PHP program.

  1. Launch the XAMPP Control Panel
    Go to the folder where you installed XAMPP (e.g., `C:\xampp`) and double-click `xampp-control.exe` to launch it. You'll be using this a lot, so creating a desktop shortcut is convenient.
  2. Start Apache
    When the Control Panel appears, find "Apache" in the "Module" list and click the "Start" button on the right side of that row.
    (Image of the XAMPP Control Panel pointing to the Apache Start button would go here)
    If successful, the background for "Apache" will turn green, and numbers like "80, 443" will appear in the "Port(s)" column. Your web server is now running!
    ※ If it fails to start with an error, the most common reason is that another app (like Skype) is already using port 80. Try closing the conflicting application and then click "Start" again.
  3. Check the `htdocs` Folder
    Next, find the folder named "`htdocs`" inside your XAMPP installation folder (`C:\xampp`). This folder is the root directory of your local server, meaning it's the top level of your website. Any file you place here can be accessed from your browser.
  4. Create a PHP File to Test
    Inside the `htdocs` folder, create a new text file and write the following single line of code.
    <?php phpinfo(); ?>
    Save the file as "`info.php`". `phpinfo()` is a useful function that displays all the current configuration information for your PHP installation.
  5. Access it from Your Browser!
    This is the final check. Open your web browser (like Chrome) and type the following into the address bar, then press Enter.
    http://localhost/info.php
    If you see a page with the PHP logo and a long list of configuration details, then you've succeeded!
    (Image of the successful phpinfo() page would go here)

Summary

Excellent work! You are now at the starting line for PHP programming. In this article, you have accomplished the following:

With this environment, you can now run and experiment with any of the PHP code you learn from now on. This feeling of being able to "run it yourself" is the most important thing in learning to program.

Now you're all set. In the next article, let's dive into learning the actual syntax of the PHP language!