How to Run a PHP File in XAMPP

Xamp, PHP, server, blog

The XAMPP suite of Web development tools, created by Apache Friends, makes it easy to run PHP (Personal Home Pages) scripts locally on your computer. Manual installation of a Web server and PHP requires in-depth configuration knowledge, but installing XAMPP on Windows only requires running an installer package. This package installs not only a Web server and PHP but also MySQL, FileZilla, Mercury, Perl, and Tomcat. These applications allow testing of full websites on your own desktop without the need to upload everything to an online Web server.

Step 1

Go to the Apache Friends website and download XAMPP for Windows. For the easiest install, download the Basic Package's "self-extracting RAR archive." Wait for the download to finish and open it to begin installing XAMPP. Click the "Install" button to start the file extraction. When the Command Prompt screen appears, press the "Enter" key at every question to accept default settings.

Step 2

Start the XAMPP program. When started, XAMPP loads itself into your icon tray. The icon is orange with a white bone-like shape in its center. Single-click the icon to expand the Control Panel. Click on the "Start" button next to "Apache" to start your Apache Web server. When Apache is running, the word "Running" will appear next to it, highlighted in green. Also start "MySQL" if your PHP scripts depend on a MySQL database to run.

Step 3

Place your PHP files in the "HTDocs" folder located under the "XAMMP" folder on your C: drive. The file path is "C:\xampp\htdocs" for your Web server. Make sure your PHP files are saved as such; they must have the ".php" file extension. Open up any Web browser on your desktop and enter "localhost" into the address box. The browser will open a list of files stored under the "HTDocs" folder on your computer. Click on the link to a PHP file and open it to run a script.

Step 4

Create any folders you need to test PHP files in under the "HTDocs" folder. If you create a folder named "scripts," then use the address "localhost/scripts" to open them in your browser.

Disclaimer: The content on this website is for general information purposes only. While we strive to provide accurate and up-to-date information, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability of the content. Some content, including images, videos, and articles, may be owned by third parties and are used on this website with permission or under applicable copyright laws. We do not claim ownership of any content that is not explicitly marked as ours. Any reliance you place on the content is therefore strictly at your own risk. In no event will we be liable for any loss or damage arising from your use of this website or its content.

Interested in hiring us for your project?

To start an initial chat, just drop an email at mail@foozawebtech.com or use the form on the contact page.