Start by downloading XAMPP by following these links to downloads and installation guides:
- Download and install XAMPP for Windows
- Download and install XAMPP for Mac
- Download and install XAMPP for Linux
Just follow the instructions on the screen during the installation process. Below are screenshots from an installation on Windows.
1. Choose the "Installer" download on the XAMPP website:
2. Run the file and choose C:\xampp as the install location:
3. You don't need to choose any "Service Sections":
4. Click "Finish" when the installation process is complete:
When you have downloaded and installed XAMPP, you can start the server and save your future PHP documents in the folder c:\xampp\htdocs on your computer and access them in the browser with the address http://localhost.
You can test whether XAMPP runs properly by following the steps below:
1. Open the program XAMPP Control Panel
2. Start the Apache server and the MySql server:
3. Create a file in Notepad (or similar text editor) named test.php (note that the file extension must be ".php" instead of ".htm").
4. Insert the following code in the file:
<?php echo "Hello World!"; ?>
5. Save the file in the folder "c:\xampp\htdocs".
6. Open the file in your browser with the address http://localhost/test.php.
If the browser writes "Hello World!" the installation is successful, and you're ready to run PHP on your computer. Otherwise, see below for how to fix common problems, see the XAMPP website for more information, or use the forums for support.
Common Xampp problems
1. Apache server won't start
If the Apache server won't start, it is probably because some other application is using port 80. Most likely Skype or Microsoft IIS.
If you use Skype: start Skype, selecting Tools > Options > Connections and un-check the use of Port 80 as an alternative port. Then close and re-start Skype.
If you have installed IIS: Follow this guide and uncheck Internet Information Server (IIS).
If none of this helps, follow these steps to find the program that is using port 80:
- Go to command prompt (Start > Run > cmd).
- Type in: netstat -aon
- You will see a list of IP numbers, port numbers and the process ID (PID).
- Look for the row with 127.0.0.1:80 and remember the process ID.
- Open up Task Manager (Start > Run > taskmgr).
- Go to Process tab, click View > Select Columns…
- Tick PID (Process Identifier)
- Search the process that has the same process ID shown in netstat and close the program.
2. I don't know where to save my PHP files
You should always save your files in the "htdocs"-folder. If you have made a standard installation in Windows (see above) the path is "c:\xampp\htdocs\":
- In Notepad choose "Save as…" under "File" in the top menu.
- Find the "\htdocs\" folder (click on the folder-icon next to the path (see image above), and type: "C:\xampp\htdocs")
- Choose "All Files" in the "Save as type" box. This is very important – otherwise, you save it as a text document and not as an PHP file.
- Now save your document as i.e. "page.php" (the ending ".php" indicates that it is an PHP file).
You can now open the file in your browser with the address http://localhost/page.php and enjoy the fruits of your labor.