Skip to content
Advertisement

phpmyadmin 403 Forbidden after php downgrade from 7.4 -> 7.3 on CentOS 7 Apache

I have acquired VPS and got it with LAMP.

CentOS Linux release 7.9.2009 (Core)
Server version: Apache/2.4.6 (CentOS)
PHP 7.4.16 (cli) (built: Mar  2 2021 10:35:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

I installed phpmyadmin and configured it’s phpmyadmin.conf file to make it accessible from browser and it was working.

Later I upgraded my PHP 5.x to 7.4. version following this tutorial: https://computingforgeeks.com/how-to-install-php-7-4-on-centos-7/

After upgrade I got memory problems with script so I tried “downgrade” to PHP 7.3. First I uninstalled my current version of PHP with: yum remove php-7-*

  • I ran this only once, later I found that I have installed other PHP 7.4 extensions and have not removed them.
  • Than I installed php73 (not sure by which tutorial)

These are my current packages with rpm -qa |grep php:

php-json-7.4.16-1.el7.remi.x86_64
php-gd-7.4.16-1.el7.remi.x86_64
php-bcmath-7.4.16-1.el7.remi.x86_64
php73-php-cli-7.3.27-1.el7.remi.x86_64
php73-2.0-1.el7.remi.x86_64
php-fedora-autoloader-1.0.1-2.el7.noarch
php-common-7.4.16-1.el7.remi.x86_64
php-pdo-7.4.16-1.el7.remi.x86_64
php-sodium-7.4.16-1.el7.remi.x86_64
oniguruma5php-6.9.6-1.el7.remi.x86_64
php-pecl-zip-1.19.2-1.el7.remi.7.4.x86_64
php-mbstring-7.4.16-1.el7.remi.x86_64
php-tidy-7.4.16-1.el7.remi.x86_64
php-mysqlnd-7.4.16-1.el7.remi.x86_64
php-xml-7.4.16-1.el7.remi.x86_64
php73-runtime-2.0-1.el7.remi.x86_64
php73-php-common-7.3.27-1.el7.remi.x86_64
php73-php-xml-7.3.27-1.el7.remi.x86_64
php73-php-pear-1.10.12-5.el7.remi.noarch
php73-php-mbstring-7.3.27-1.el7.remi.x86_64
php-tcpdf-6.2.26-1.el7.noarch
phpMyAdmin-4.4.15.10-4.el7.noarch
php-cli-7.4.16-1.el7.remi.x86_64
php-process-7.4.16-1.el7.remi.x86_64
php73-php-json-7.3.27-1.el7.remi.x86_64
php73-php-process-7.3.27-1.el7.remi.x86_64
php-php-gettext-1.0.12-1.el7.noarch
php-tcpdf-dejavu-sans-fonts-6.2.26-1.el7.noarch

This is what I got when ran yum list installed | grep -i php:

oniguruma5php.x86_64                6.9.6-1.el7.remi                @remi-safe
php-bcmath.x86_64                   7.4.16-1.el7.remi               @remi-php74
php-cli.x86_64                      7.4.16-1.el7.remi               @remi-php74
php-common.x86_64                   7.4.16-1.el7.remi               @remi-php74
php-fedora-autoloader.noarch        1.0.1-2.el7                     @epel
php-gd.x86_64                       7.4.16-1.el7.remi               @remi-php74
php-json.x86_64                     7.4.16-1.el7.remi               @remi-php74
php-mbstring.x86_64                 7.4.16-1.el7.remi               @remi-php74
php-mysqlnd.x86_64                  7.4.16-1.el7.remi               @remi-php74
php-pdo.x86_64                      7.4.16-1.el7.remi               @remi-php74
php-pecl-zip.x86_64                 1.19.2-1.el7.remi.7.4           @remi-php74
php-php-gettext.noarch              1.0.12-1.el7                    @epel
php-process.x86_64                  7.4.16-1.el7.remi               @remi-php74
php-sodium.x86_64                   7.4.16-1.el7.remi               @remi-php74
php-tcpdf.noarch                    6.2.26-1.el7                    @epel
php-tcpdf-dejavu-sans-fonts.noarch  6.2.26-1.el7                    @epel
php-tidy.x86_64                     7.4.16-1.el7.remi               @remi-php74
php-xml.x86_64                      7.4.16-1.el7.remi               @remi-php74
php73.x86_64                        2.0-1.el7.remi                  @remi-safe
php73-php-cli.x86_64                7.3.27-1.el7.remi               @remi-safe
php73-php-common.x86_64             7.3.27-1.el7.remi               @remi-safe
php73-php-json.x86_64               7.3.27-1.el7.remi               @remi-safe
php73-php-mbstring.x86_64           7.3.27-1.el7.remi               @remi-safe
php73-php-pear.noarch               1:1.10.12-5.el7.remi            @remi-safe
php73-php-process.x86_64            7.3.27-1.el7.remi               @remi-safe
php73-php-xml.x86_64                7.3.27-1.el7.remi               @remi-safe
php73-runtime.x86_64                2.0-1.el7.remi                  @remi-safe
phpMyAdmin.noarch                   4.4.15.10-4.el7                 @epel

My phpmyadmin.conf looked like this (when working):

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
      # Apache 2.4
      <RequireAny>
       Require ip 62.75.146.76
       Require ip ::1
       Require all granted
      </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from All
     Allow from ::1
   </IfModule>
</Directory>

and than I changed it to this (but it still not working):

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Allow from All
   </IfModule>
</Directory>

What I got searching was that 403 Forbidden could be due to wrong php installation, so I was thinking to remove all php 7.3 and 7.4 packages and install clean php 7.3. with common packages. Is that correct approach here? And if it is please help with command to install php 7.3 properly


My phpMyAdmin.conf file after new installation:

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8
   <IfModule mod_authz_core.c>
      # Apache 2.4
      <RequireAny>
       Require ip 62.75.146.76
       Require ip ::1
       Require all granted
      </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from All
     Allow from ::1
   </IfModule>
#   Require local
</Directory>

Advertisement

Answer

Your installation seems a mess

1/ 2 PHP Stacks

You have both PHP 7.4 (php-* packages) and 7.3 installed (php73-php-* packages)

Read: Difference between php-* and php##-php-* packages ?

I recommend you remove everything

yum remove php*

and start a clean installation following the Wizard instructions.

yum-config-manager --disable 'remi-php*'
yum-config-manager --enable   remi-php73
yun install php

2/ you don’t have any PHP engine for your web server

You need mod_php (“php” package) used by default on CenOS 7 or php-fpm

yum install mod_php

Notice: php-fpm is now used by default on CentOS 8

3/ old phpMyAdmin

You are using an old phpMyAdmin v4 from EPEL which is fine for old PHP version 5.4 provided by default on CentOS 7, but which is not compatible with recent PHP versions

You should use the new phpMyAdmin v5 (from “remi” repository)

yum --enablerepo=remi install phpMyAdmin
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement