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:
- Enable Error Reporting:
In yourindex.php, add at the top:ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); - Check File Location:
Make sureindex.phpis inside:C:/xampp/htdocs/ - Check for PHP Syntax Errors:
Run:php -l C:/xampp/htdocs/index.php - Check Apache Config:
EnsureDirectoryIndexis correctly set:- Open
httpd.conf - Look for:
DirectoryIndex index.php index.html
- Open
- Restart Apache.
🍏 Fix on macOS
✅ Step-by-Step:
- Open Terminal and enable error reporting:
Edit your PHP file or set PHP display settings in:/Applications/XAMPP/xamppfiles/etc/php.iniSet:display_errors = On error_reporting = E_ALL - Verify File Placement:
File should be in:/Applications/XAMPP/htdocs/ - Check Permissions:
chmod 644 /Applications/XAMPP/htdocs/index.php - Restart Apache:
sudo /Applications/XAMPP/xamppfiles/xampp restartapache
🐧 Fix on Linux/Ubuntu
✅ Step-by-Step:
- Enable PHP Errors:
In/opt/lampp/etc/php.ini, set:display_errors = On error_reporting = E_ALL - Check File Location:
Ensure yourindex.phpis in:/opt/lampp/htdocs/ - Verify Apache DirectoryIndex:
In/opt/lampp/etc/httpd.conf, confirm:DirectoryIndex index.php index.html - Check Permissions:
chmod 644 /opt/lampp/htdocs/index.php - 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.phpto 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.