Apologies for the long read, but I think it makes sense to include as much detail as I can upfront, rather than waiting for people to ask for the various configs, logs, etc.
I have an old PC running XP with the One Core API installed.
I'm using this to test Apache 2.4.38 with multiple PHP versions. Everything works perfectly, except that PHP 7.2 and 7.3 return a 404 status for all php files with the message "No input file specified". The Apache logs, if I'm reading them correctly, show that php-cgi.exe is being called correctly and is responsible for returning this status even though the files exist.
SysInternals Process Monitor shows that Apache's "httpd.exe" finds the php files no problem. Following this, all PHP versions up to 7.1 check for both "user.ini" and the requested php file. Versions 7.2 and 7.3 however, are only checking for "user.ini" and don't try to access the requested php file at all. Despite this, they return a 404 error with the message "No input file specified".
I have now scaled everything down to a bare bones working configuration which is all shown below if anyone wants to try it out for themselves. Apache and all PHP builds are installed in a folder named according to their 5 digit Version ID. There is one test site "test2.local" which contains a single index file.
- Everything is 32bit and all PHP versions are non-thread-safe (nts) versions.
- Apache is the current build from Apache Lounge (as at 8 Feb 2019).
- PHP <=5.5 are the last builds for each version.
- PHP >=5.6 are all current builds (as at 8 Feb 2019).
- PHP builds are all pre-built binaries from php.net.
- All VC runtimes are installed and working (2008, 2012, 2017).
- To keep things simple, no PHP extensions are being loaded.
- All PHP versions have their own "php.ini" file in their own folder.
- All binaries have been checked and there are no missing dependencies except for the usual culprits (PHP extensions that rely on 3rd party software that is not installed).
- All versions of "php.exe" and "php-cgi.exe" work perfectly from the command line and without any errors logged to the PHP error log.
- All versions of "php-cgi.exe" up to 7.1 work perfectly with Apache, also without any errors logged.
- Versions 7.2 and 7.3 of "php-cgi.exe" show 404 status for all php files in the Apache error log, but again, don't log anything to the PHP error log.
Folder structure:
Apache (Logs folder contains both Apache and PHP logs):
2.4.38 ....... D:\www\APACHE\20438
Logs ......... D:\www\APACHE\logs
PHP:
5.2.17 ....... D:\www\PHP\50217
5.3.29 ....... D:\www\PHP\50329
5.4.45 ....... D:\www\PHP\50445
5.5.17 ....... D:\www\PHP\50538
5.6.40 ....... D:\www\PHP\50640
7.0.33 ....... D:\www\PHP\70033
7.1.26 ....... D:\www\PHP\70126
7.2.15 ....... D:\www\PHP\70215
7.3.02 ....... D:\www\PHP\70302
Virtual Hosts:
test2.local .. D:\www\sites\test2 (contains 1 file: index.php)
Contents of "D:\www\sites\test2\index.php":
<?php
echo <<<EOF
<!DOCTYPE html>
<html>
<head><meta charset="us-ascii"><title>test2.local</title></head>
<body><h1>test2.local</h1></body>
</html>
EOF;
?>
The Apache configuration is as minimal as I think it can be:
# Apache 2.4.38 Configuration
Define SRVROOT "D:\www\APACHE\20438"
Define LOGPATH "D:\www\APACHE\logs"
Define DOCROOT "D:\www\sites"
# Here I simply uncomment the PHP version I want to test and then restart Apache.
#Define PHPVER 50217
#Define PHPVER 50329
#Define PHPVER 50445
#Define PHPVER 50538
#Define PHPVER 50640
#Define PHPVER 70033
Define PHPVER 70126
#Define PHPVER 70215
#Define PHPVER 70302
ErrorLog "${LOGPATH}\apache_20438.txt"
LogLevel trace8
ServerRoot "${SRVROOT}"
DocumentRoot "${DOCROOT}"
ServerName apache.local
Listen 192.168.0.1:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so
LoadModule fcgid_module modules/mod_fcgid.so
<Directory />
Options Indexes ExecCGI FollowSymLinks
AllowOverride None
Require all granted
</Directory>
TypesConfig conf/mime.types
AddType application/x-httpd-php .php
DirectoryIndex index.php index.htm
FcgidInitialEnv SystemRoot "C:\Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "D:\www\PHP\${PHPVER}\tmp"
FcgidInitialEnv TMP "D:\www\PHP\${PHPVER}\tmp"
FcgidInitialEnv windir "C:\WINDOWS"
FcgidInitialEnv PHPRC "D:\www\PHP\${PHPVER}"
FcgidInitialEnv PATH "D:\www\PHP\${PHPVER};D:\www\PHP\${PHPVER}\ext;${PATH}"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
FcgidMaxRequestsPerProcess 10
FcgidMaxProcesses 15
FcgidIOTimeout 50
FcgidIdleTimeout 50
FcgidFixPathinfo 0
FcgidWrapper "D:/www/PHP/${PHPVER}/php-cgi.exe" .php
AddHandler fcgid-script .php
<VirtualHost *:80>
# This forces unknown addresses to the default site.
DocumentRoot "${DOCROOT}"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "${DOCROOT}\test2"
ServerName test2.local
</VirtualHost>
All PHP configurations are the same except that versions 7.1 onwards include the "default_charset" directive, which if not present, causes a 500 Internal Server Error. I found this solution for 7.1 (which also didn't work originally, but does now) thanks to the migration pages at php.net. I can't find anything that indicates that further changes are needed for 7.2 or 7.3.
- http://php.net/manual/en/migration71.php
- http://php.net/manual/en/migration72.php
- http://php.net/manual/en/migration73.php
The full contents of the "php.ini" files are as follows (XXXXX = Version ID):
[PHP]
; Paths at the top for ease of copying configurations, which
; in this case you would only need to edit these two lines.
extension_dir="D:/www/PHP/XXXXX/ext"
error_log="D:/www/APACHE/logs/php_XXXXX.txt"
allow_url_fopen=On
allow_url_include=Off
asp_tags=Off
auto_globals_jit=On
cgi.fix_pathinfo=0
cgi.force_redirect=0
; default_charset must be set for PHP 7.1 onwards
default_charset="us-ascii"
default_mimetype="text/html"
default_socket_timeout=60
display_errors=On
display_startup_errors=On
engine=On
error_reporting=E_ALL
expose_php=On
html_errors=Off
ignore_repeated_errors=On
ignore_repeated_source=Off
implicit_flush=Off
log_errors=On
log_errors_max_len=1024
magic_quotes_gpc=Off
magic_quotes_runtime=Off
magic_quotes_sybase=Off
max_execution_time=0
max_input_time=60
memory_limit=128M
output_buffering=On
post_max_size=16M
precision=14
register_argc_argv=Off
register_globals=Off
register_long_arrays=Off
report_memleaks=On
request_order="GP"
serialize_precision=100
short_open_tag=On
; Default value for user_ini.filename is ".user.ini". I remove the first
; period here for ease. (In XP, creating files that begin with a period
; usually causes an error unless done from the command prompt.)
user_ini.filename="user.ini"
variables_order="EGPCS"
y2k_compliance=On
zlib.output_compression=Off
(I've read in a lot of places that the fix path info settings should be "FcgidFixPathinfo=1" and "cgi.fix_pathinfo=1", but I tried this without success. In fact, turning on those settings only had the effect of both the "SCRIPT_NAME" and "PHP_SELF" variables being set to "D:/index.php" instead of "/index.php" in all working PHP versions. In other words, turning it on broke things instead of fixing anything.)
With everthing up and running, testing is as simple as requesting the page at "http://test2.local/index.php". Results for PHP <=7.1 are all the same, so I'll use the 7.1 logs. Likewise, the results for 7.2 and 7.3 are the same, so I'll use the 7.2 logs. No PHP version logged any errors or crashed. Each version loaded successfully on the first request and continued to run happily until Apache was restarted.
Apache startup log (All PHP versions):
Setting LogLevel for all modules to trace8
Setting LogLevel for all modules to trace8
AH00455: Apache/2.4.38 (Win32) mod_fcgid/2.3.9 configured -- resuming normal operations
AH00456: Apache Lounge VC15 Server built: Jan 18 2019 12:31:19
AH00094: Command line: 'D:\\www\\APACHE\\20438\\bin\\httpd.exe -d D:/www/APACHE/20438 -E D:/www/APACHE/logs/apache_20438.txt'
AH02639: Using SO_REUSEPORT: no (0)
AH00418: Parent: Created child process 3428
AH00402: Parent: Sent the scoreboard to the child
Setting LogLevel for all modules to trace8
Setting LogLevel for all modules to trace8
AH00453: Child process is running
AH00391: Child: Retrieved our scoreboard from the parent.
AH00403: Child: Waiting for data for listening socket 192.168.0.1:80
AH00408: Parent: Duplicating socket 324 (192.168.0.1:80) and sending it to child process 3428
AH00411: Parent: Sent 1 listeners to child 3428
AH00407: Child: retrieved 1 listeners from parent
AH00352: Child: Acquired the start mutex.
AH00354: Child: Starting 64 worker threads.
mpm child 3428 (gen 0/slot 0) started
AH00334: Child: Accept thread listening on 192.168.0.1:80 using AcceptFilter connect
Apache log for requesting "http://test2.local/index.php" (PHP 7.1):
Request received from client: GET /index.php HTTP/1.1
Headers received from client:
Host: test2.local
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
AH01626: authorization result of Require all granted: granted
AH01626: authorization result of <RequireAny>: granted
request authorized without authentication by access_checker_ex hook: /index.php
mod_fcgid: server test2.local:D:/www/PHP/70126/php-cgi.exe(532) started
Headers from script 'index.php':
X-Powered-By: PHP/7.1.26
Content-type: text/html; charset=us-ascii
Response sent with status 200, headers:
Date: Mon, 18 Feb 2019 01:31:39 GMT
Server: Apache/2.4.38 (Win32) mod_fcgid/2.3.9
X-Powered-By: PHP/7.1.26
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=us-ascii
brigade contains: bytes: 256, non-file bytes: 256, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 395, non-file bytes: 395, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 400, non-file bytes: 400, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 400, non-file bytes: 400, eor buckets: 1, morphing buckets: 0
will flush because of FLUSH bucket
seen in brigade so far: bytes: 400, non-file bytes: 400, eor buckets: 1, morphing buckets: 0
flushing now
total bytes written: 400
brigade contains: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
will flush because of FLUSH bucket
seen in brigade so far: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
flushing now
total bytes written: 400
brigade contains: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
Process Monitor Screenshot for "http://test2.local/index.php" (PHP 7.1):
Apache log for requesting "http://test2.local/index.php" (PHP 7.2):
Request received from client: GET /index.php HTTP/1.1
Headers received from client:
Host: test2.local
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
AH01626: authorization result of Require all granted: granted
AH01626: authorization result of <RequireAny>: granted
request authorized without authentication by access_checker_ex hook: /index.php
mod_fcgid: server test2.local:D:/www/PHP/70215/php-cgi.exe(808) started
Headers from script 'index.php':
Status: 404 Not Found
Status line from script 'index.php': 404 Not Found
X-Powered-By: PHP/7.2.15
Content-type: text/html; charset=us-ascii
Response sent with status 404, headers:
Date: Mon, 18 Feb 2019 01:34:54 GMT
Server: Apache/2.4.38 (Win32) mod_fcgid/2.3.9
X-Powered-By: PHP/7.2.15
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=us-ascii
brigade contains: bytes: 263, non-file bytes: 263, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 294, non-file bytes: 294, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 299, non-file bytes: 299, eor buckets: 0, morphing buckets: 0
brigade contains: bytes: 299, non-file bytes: 299, eor buckets: 1, morphing buckets: 0
will flush because of FLUSH bucket
seen in brigade so far: bytes: 299, non-file bytes: 299, eor buckets: 1, morphing buckets: 0
flushing now
total bytes written: 299
brigade contains: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
will flush because of FLUSH bucket
seen in brigade so far: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
flushing now
total bytes written: 299
brigade contains: bytes: 0, non-file bytes: 0, eor buckets: 0, morphing buckets: 0
Process Monitor Screenshot for "http://test2.local/index.php" (PHP 7.2):
Any help figuring out this mystery will be much appreciated. Apologies again for the lengthy read.