Diagnosing PHP Versions on Third-Party Infrastructure
Determining the underlying PHP version running on a remote server without direct file system access is a common constraint in modern web development. You might be debugging a client application hosted on a platform you cannot touch, or perhaps you are analyzing a legacy system where SFTP credentials have been revoked. Since you cannot drop a simple <?php echo PHP_VERSION; ?> file into the document root to capture the output, you must rely on external signals that the web server exposes by default.
The most direct approach involves inspecting the HTTP headers returned by the application. Many PHP installations, particularly those running as CGI scripts or via FastCGI (like PHP-FPM), include a Server-Signature header that explicitly states the version string. You can retrieve this using standard command-line tools like curl.
curl -I https://www.abc.com
Look for a line in the response headers resembling Server: Apache/2.4.41 (Ubuntu) PHP/7.4.33 FPM. If the signature is present, you have your answer immediately. However, relying on this header is often risky. Modern security best practices frequently involve disabling or obfuscating server signatures to prevent fingerprinting attacks. If the Server-Signature header is missing, or if it only reveals Apache/Nginx details while omitting PHP specifics, you need an alternative vector.
In scenarios where headers are stripped, the application's own error reporting becomes your primary diagnostic tool. You can trigger a generic PHP error to force the server to display its configuration details. Since you cannot create a file, you must inject code via the URL query string or POST data if the framework supports it. For instance, accessing a known non-existent route in Laravel often triggers a detailed error page depending on the environment.
Alternatively, you can attempt to trigger a specific exception that exposes the stack trace and underlying configuration. If the server is misconfigured and displays full error pages (which is bad for production but common on staging environments), the footer of an error page often contains X-Powered-By: PHP/7.x.x. Note that this header is deprecated and often disabled by default in newer PHP versions to improve security posture.
If neither headers nor error pages yield results, you are forced to use external scanning tools or rely on metadata exposed by the hosting platform itself. Tools like WhatWP or built-in diagnostics panels provided by cloud providers (AWS, Google Cloud, Azure) often list the runtime stack associated with a domain. These platforms maintain an inventory of their infrastructure; while they may not expose the specific version for every single instance in a public API, their support documentation or dashboard typically lists the supported and default versions for that plan.
There is also the nuance of shared hosting versus managed infrastructure. On shared hosts, the PHP version is usually uniform across all domains on the server, but you rarely have visibility into which specific OS kernel or PHP build is active. In these cases, checking the User-Agent string of the server logs (if accessible via a public dashboard) might reveal clues about the browser rendering the site, though this doesn't directly identify the PHP version.
Finally, consider the possibility that the application framework itself provides this information. Laravel, for example, often includes middleware or configuration checks that could theoretically be exposed through specific API endpoints or health check routes if they are publicly accessible. If you control any part of the URL path, checking a route designed to return JSON metadata might include the php_version key, provided the developer included it in the payload.
Ultimately, without write access, you are limited to what the server chooses to broadcast. If the Server-Signature is missing and error reporting is disabled, identifying the exact PHP version becomes a probabilistic exercise based on the hosting provider's known configurations rather than a definitive technical fact.
