How to Set Up a PHP Development Environment (XAMPP / LAMP / MAMP)

🚀 How to Set Up a PHP Development Environment (XAMPP / LAMP / MAMP)

So you want to start coding in PHP but don’t know where to begin?
No worries! ❤️ In this guide, I’ll walk you through how to set up your local PHP development environment using tools like XAMPP, LAMP, or MAMP.

No more messing with complicated terminal commands (unless you want to 😉). Let’s keep it simple and fun!

🧠 What’s a PHP Development Environment?

When you’re coding PHP, your browser can’t run PHP files on its own—it needs a server. That’s where a local development environment comes in.

You need 3 main things:

  • PHP – the scripting language
  • MySQL/MariaDB – the database engine
  • Apache or Nginx – the web server

Instead of installing these separately, we use bundles like XAMPP, MAMP, or LAMP that include everything!

💻 Option 1: XAMPP (Windows, macOS, Linux)

XAMPP stands for:
X = Cross-platform
A = Apache
M = MySQL
P = PHP
P = Perl

🔧 Steps to Install XAMPP:

  • Download XAMPP
    Go to https://www.apachefriends.org
    Choose your OS and download the installer.
  • Install XAMPP
    Run the installer and follow the prompts (you can skip Perl).
  • Open XAMPP Control Panel
    Start Apache and MySQL.
  • Create a PHP File
    Go to the htdocs folder:
    On Windows:
Makefile
C:\xampp\htdocs

Create a file called index.php:

PHP
<?php
echo "Hello from PHP!";
?>
  • Open in Browser
    Go to:
Bash
http://localhost/index.php

🎉 You should see:

Bash
Hello from PHP!

🐧 Option 2: LAMP Stack (Linux)

LAMP = Linux + Apache + MySQL + PHP
Perfect if you’re using Ubuntu, Debian, or any other Linux distro.

🔧 Steps to Install LAMP on Ubuntu:

Open your terminal and run:

Bash
sudo apt update
sudo apt install apache2
sudo apt install mysql-server
sudo apt install php libapache2-mod-php php-mysql

Restart Apache:

Bash
sudo systemctl restart apache2

Create your PHP file:

Bash
sudo nano /var/www/html/index.php

Paste this:

PHP
<?php
echo "Hello from LAMP!";
?>

Save it, then go to browser and type below URL:

Bash
http://localhost/index.php

Boom 💥! You’re now running PHP on Linux.

🍏 Option 3: MAMP (macOS and Windows)

MAMP is great for Mac users (also works on Windows).

🔧 Steps to Install MAMP:

  • Download it from https://www.mamp.info
  • Install it like a regular Mac app
  • Open MAMP, then click Start Servers
  • Go to terminal and type this:
Bash
/Applications/MAMP/htdocs
  • Create a new file: hello.php
PHP
<?php
echo "Hi from MAMP!";
?>
  • Visit in browser:
Bash
http://localhost:8888/hello.php

You’re good to go! 🍎

💬 Quick Comparison

FeatureXAMPPLAMPMAMP
OSAllLinux onlymacOS / Win
InterfaceGUICLIGUI
Beginner-Friendly⚠️ Intermediate

🧪 Bonus: Use PHP Built-in Server (No Apache Needed)

If you have PHP installed already (e.g. via Homebrew, Chocolatey, or manually), you can run:

Bash
php -S localhost:8000

Put your files in that directory, and open http://localhost:8000
Super useful for testing small projects!

🙌 Wrapping Up

Setting up PHP on your local machine doesn’t have to be scary. Whether you go with XAMPP, LAMP, or MAMP, you now have the power to build dynamic, database-driven websites right from your computer.

So go ahead — open that code editor, fire up your server, and start writing PHP like a champ! 💪


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *