Hosting

How to Run a PHP Project Locally (Step-by-Step Guide)

By Site Owner · April 15, 2026 · 3 min read

 

🔧 Step 1: Install XAMPP

  • Download and install XAMPP.
  • Make sure Apache (and MySQL if needed) is installed.

▶️ Step 2: Start Apache Server

  1. Open XAMPP Control Panel
  2. Click Start next to Apache
  3. (Optional) Start MySQL if your project uses a database

📁 Step 3: Place Project in htdocs

Move your project into:

C:\xampp\htdocs\your-project-folder

Example:

C:\xampp\htdocs\blog-app

🌐 Step 4: Run Project on Your Own Laptop

Open browser and visit:

http://localhost/your-project-folder

✅ Your project should now run locally.


📡 Step 5: Access Project from Mobile or Other Laptop

This is where most people get confused — follow carefully.


📶 شرط (Important Requirement)

All devices must be connected to the same network:

  • Same WiFi
    OR
  • Same mobile hotspot

👉 Example:
Your laptop + your phone both connected to same WiFi router OR your laptop hotspot.


🔍 Step 5.1: Find Your Computer IP Address

On Windows:

  1. Open Command Prompt
  2. Run:
ipconfig
  1. Look for:
IPv4 Address: 192.168.X.X

Example:

192.168.1.5

🌍 Step 5.2: Use IP Instead of Localhost

On your mobile or another laptop, open browser and type:

http://192.168.1.5/your-project-folder

👉 Replace:

  • 192.168.1.5 with your actual IP
  • your-project-folder with your project name

⚠️ Step 5.3: Allow Firewall Access

Sometimes it won’t work due to firewall blocking.

Fix:

  1. Open Windows Defender Firewall
  2. Click Allow an app through firewall
  3. Allow:
    • Apache HTTP Server
  4. Or temporarily turn off firewall (for testing only)

⚙️ Step 5.4: Check Apache Port

Default Apache runs on:

Port 80

If changed (example: 8080), use:

http://192.168.1.5:8080/your-project-folder

🧪 Step 6: Test Connectivity

If it doesn’t work:

  • Try opening:
http://192.168.1.5

If XAMPP dashboard opens → network is working ✅


❗ Common Issues & Fixes

🚫 1. Mobile Cannot Access Site

  • Not on same WiFi ❌
  • Wrong IP address ❌
  • Firewall blocking ❌

🔥 2. Apache Running But Not Accessible

  • Check firewall settings
  • Restart Apache
  • Use correct port

🌐 3. IP Address Keeps Changing

  • This is normal (DHCP)

👉 Solution:

  • Re-check IP using ipconfig
  • Or set static IP (advanced)

🗄️ 4. Database Not Working on Mobile

If your project connects to database:

  • Make sure DB host is:
localhost

✔ Works fine because DB runs on same server


📂 5. Project Not Found

  • Ensure project is inside:
htdocs
  • URL spelling must match folder name exactly

🧠 Pro Tips

  • Use hotspot from your laptop for quick testing
  • Keep project folder name simple (no spaces)
  • Use .env file for config if project supports it
  • Restart Apache after any config changes

✅ Final Flow Summary

  1. Install XAMPP
  2. Start Apache
  3. Put project in htdocs
  4. Run on:

    http://localhost/project
  5. Find IP using ipconfig
  6. Access on mobile:

    http://YOUR-IP/project
  7. Ensure same network + firewall allowed

🚀 Conclusion

Now you can:

✔ Run PHP project locally
✔ Access it from your phone
✔ Share it with other devices on same network

This is very useful for:

  • Testing responsive design
  • Demo to clients
  • Multi-device debugging

 

Next →

Comments

No comments yet.