PHP Not Working in XAMPP
If you are deploying a local stack like XAMPP alongside IIS on Windows and encountering blank pages instead of rendered PHP output, the issue usually stems from a conflict between multiple web servers listening on the same port or a misconfigured Apache module. In your specific scenario, you have successfully served xampp/index.php but cannot access .php files located in the htdocs directory. This discrepancy often points to how Apache is routing requests versus where the physical files reside.
When XAMPP and IIS coexist, they can easily collide if port assignments aren't strictly isolated. You mentioned changing the port to 81 in httpd.conf. While modifying the Listen directive is a valid step, it is not enough on its own. Apache needs to know exactly which URL paths map to its virtual host configuration. If IIS is intercepting requests for certain paths before they reach Apache, or if Apache's DirectoryIndex and file handling are misaligned with your URL structure, you will see the HTML of a file instead of the processed PHP output.
The core technical detail here involves the Apache module responsible for processing scripts: mod_php. If this module is not enabled or loaded correctly within the XAMPP installation, Apache will treat .php files as plain text or return a 500 Internal Server Error, which can sometimes manifest as a blank page depending on your browser's error handling.
To resolve this, verify that libphp.dll is included in the LoadModule section of your httpd.conf. In XAMPP 1.7.7, you must manually ensure the line looks like this:
LoadModule php5_module "c:/xampp/apache/modules/php5apache2_2.dll"
Note: The exact DLL name depends on your PHP version and whether you are using Apache 2.2 or 2.4. If you are unsure, check the modules directory for available extensions and ensure the correct one is loaded. Without this, Apache simply cannot execute PHP code, resulting in blank outputs or raw script errors.
Furthermore, IIS integration requires careful path mapping. If you are accessing files directly via the XAMPP URL (e.g., http://localhost/your-project/file.php), ensure that your virtual host configuration in Apache's httpd-vhosts.conf (or httpd-ssl.conf) explicitly points to the correct document root. A common pitfall is defining a virtual host for port 81 but failing to disable IIS from handling those specific requests, causing IIS to return a default page or reject the connection entirely.
Additionally, check your .htaccess files within the htdocs directory. If they contain strict security rules (like deny from all) or incorrect AddHandler directives, they can prevent execution even if the global configuration is correct. Ensure that AllowOverride All is present in the <Directory "c:/xampp/htdocs"> block of your main config to allow local overrides to take effect.
If you are moving toward a production-grade stack where XAMPP's tight integration with IIS becomes a bottleneck, consider decoupling the environments. Running a dedicated PHP-FPM instance behind a reverse proxy like Nginx is often more robust than forcing Apache and IIS to share resources on Windows. For developers building modern applications, specifically those using frameworks like Laravel, this separation of concerns simplifies deployment significantly. Resources from https://laravelcompany.com often highlight how separating the web server from the application handler can streamline maintenance and performance tuning in complex local setups.
Ultimately, the solution lies in ensuring Apache is the sole arbiter for your XAMPP port, that mod_php is explicitly loaded, and that your virtual host mappings accurately reflect the physical file structure in htdocs.
