index.php Not Working or Showing Blank Page – XAMPP Fix for Windows, macOS & Linux

index.php Not Working or Showing Blank Page

Facing a blank screen or no response from index.php in XAMPP? Here’s how to fix it on Windows, macOS, and Linux/Ubuntu step by step.


🧩 Introduction

When working with XAMPP, opening index.php and seeing a blank page or no output can be frustrating. It may feel like nothing is working, but it’s usually caused by basic misconfigurations or code issues.

Let’s explore the possible causes and platform-specific solutions to fix this error.


❗ Common Causes

  • PHP errors hidden (error reporting off)
  • Faulty Apache/PHP configuration
  • Wrong file encoding or permissions
  • Browser caching
  • Corrupt or missing PHP code

🖥️ Fix on Windows

✅ Step-by-Step:

  1. Enable Error Reporting:
    In your index.php, add at the top: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
  2. Check File Location:
    Make sure index.php is inside: C:/xampp/htdocs/
  3. Check for PHP Syntax Errors:
    Run: php -l C:/xampp/htdocs/index.php
  4. Check Apache Config:
    Ensure DirectoryIndex is correctly set:
    • Open httpd.conf
    • Look for: DirectoryIndex index.php index.html
  5. Restart Apache.

🍏 Fix on macOS

✅ Step-by-Step:

  1. Open Terminal and enable error reporting:
    Edit your PHP file or set PHP display settings in: /Applications/XAMPP/xamppfiles/etc/php.ini Set: display_errors = On error_reporting = E_ALL
  2. Verify File Placement:
    File should be in: /Applications/XAMPP/htdocs/
  3. Check Permissions: chmod 644 /Applications/XAMPP/htdocs/index.php
  4. Restart Apache: sudo /Applications/XAMPP/xamppfiles/xampp restartapache

🐧 Fix on Linux/Ubuntu

✅ Step-by-Step:

  1. Enable PHP Errors:
    In /opt/lampp/etc/php.ini, set: display_errors = On error_reporting = E_ALL
  2. Check File Location:
    Ensure your index.php is in: /opt/lampp/htdocs/
  3. Verify Apache DirectoryIndex:
    In /opt/lampp/etc/httpd.conf, confirm: DirectoryIndex index.php index.html
  4. Check Permissions: chmod 644 /opt/lampp/htdocs/index.php
  5. Restart Apache: sudo /opt/lampp/lampp restartapache

🧪 Bonus Debug Tips (All OS)

  • Open browser dev tools (F12) → Console tab to catch client-side errors.
  • Use view-source:http://localhost/index.php to confirm content.
  • Try printing simple content like: <?php echo "Working!"; ?>

📌 Conclusion

A blank page from index.php is usually due to a hidden error or Apache misconfiguration. Enabling error reporting, correcting permissions, and verifying Apache settings should solve the issue—no matter your OS.


💬 Need Help Debugging?

Post your Apache config or a snippet of your index.php in the comments—I’ll check it for you.


Leave a Reply

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