PHP 7.2 on RHEL7 – How to Fix phpMyAdmin

phpmyadminredhatrhel7

I've upgraded PHP from 5.4 to PHP 7.2 on a vanilla web server running RHEL7. The source of the PHP7.2 is RHSC using yum. I've also installed the standard supporting libraries for this version, including rh-php72-php-fpm, and started it as a service.

I do not access the web server from localhost, but over the web. For now, I have "Require all granted" in phpMyAdmin.conf (will lock down when I get things working again).

This server has SELinux enabled – but this has always been the case and I do not think SELinux is the cause of this problem (for one thing: disabling SELinux makes no difference).

When PHP 7.2 is enabled for the Apache 2.4 web-server, phpMyAdmin stops working (the rest of the site looks OK).

I installed phpMyAdmin ages ago using sudo yum install phpmyadmin – and haven't touched it since.

The error message on the web page is "File not found". This is different from a regular 404-response (i.e. requesting a file that really does not exist). The screen dumps below shows the difference. The first is when requesting /phpmyadmin (where index.php exists), the second when requesting /phpmyadmin/zzzz (which does not exist). Requesting .html-files that exists in this directory works.

Two screens

The error messages in the error_log for Apache are:

[…] [proxy_fcgi:error] […] […] AH01071: Got error: 'Primary script unknown\n'
[…] [autoindex:error] […] […] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

I believe these error message indicates that Apache does not recognize index.php as a legitimate script file.

However, I've checked, and the configuration for Apache says:

<IfModule dir_module>
  DirectoryIndex index.html index.php
</IfModule>

Apache has no problem loading index.php from any other directory that is part of the web site.

My Apache configuration is mostly the one that ships with RHEL7. To get the configuration file for PHP-FPM loaded, I've put the following at the end of httpd.conf:

#Load config files in the "/etc/httpd/conf.d" directory, if any.
<IfModule proxy_module>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
</IfModule>
IncludeOptional conf.d/*.conf

The stuff within the IfModule conditional are not part of the version that ships with RHEL7. There are no other changes to httpd.conf.

I've restarted Apache (and even rebooted the web server), but so far, no luck – PHP 7.2 works fine, but not for phpMyAdmin.

If anyone has seen this before, and knows the solution, great! But also suggestions for how to debug this will be welcome.

Best Answer

I've managed to come up with a workaround: If I create a symbolic link from my webroot to /usr/share/phpMyAdmin, phpMyAdmin becomes available on that path. I.e. the following command in the webroot makes phpMyAdmin available using the path /phpmyadmin:

ln -s /usr/share/phpMyAdmin/ phpmyadmin

I've no idea if this is the canonical solution to this problem, so please feel welcome to provide alternative answers - but at least this symlink works.

Related Topic