agyanadda@gmail.com

PHP Installation

PHP Basics 1 min read Updated Dec 1, 2026 Topic 2 of 36

PHP files need a server to run. You cannot just double-click a .php file.

Option 1: XAMPP (Windows, Mac, Linux)

  1. Download and install XAMPP (Apache + PHP + MySQL)
  2. Open the XAMPP Control Panel and Start Apache and MySQL
  3. Put your files in C:\xampp\htdocs\myproject
  4. Open http://localhost/myproject/ in the browser

Option 2: Laragon (Windows)

A fast, light alternative. Every folder in www gets a nice URL like http://myproject.test.

Option 3: PHP built-in server

If PHP is installed, run this in your project folder:

php -S localhost:8000

Check your version

php -v

Create info.php with <?php phpinfo(); to see all settings (delete it afterwards — it shows private details).

Code editor

Use VS Code with the PHP Intelephense extension.

Example

Example — Check that PHP works PHP
<?php
// Save as test.php in htdocs and open http://localhost/test.php
echo 'PHP is working!<br>';
echo 'PHP version: ' . phpversion() . '<br>';
echo 'Server software: ' . $_SERVER['SERVER_SOFTWARE'];

Output: PHP is working! / PHP version: 8.3.x / Server software: Apache/2.4.x (your exact versions may differ).

Test Yourself With Exercises

Exercise 1 Multiple Choice

In XAMPP, which folder holds your PHP projects?

Exercise 2 True / False

You can run a .php file by double-clicking it like an HTML file.

Exercise 3 Fill in the Blank

The command php -___ shows the installed PHP version.

Frequently Asked Questions

Another program (often Skype or IIS) is using port 80. Close it, or change Apache's port to 8080 in httpd.conf and open http://localhost:8080.