4

I get an permission error when i try to run localhost/phpmyadmin on Centos 7:

Forbidden

You don't have permission to access /phpmyadmin on this server.

I have searched and did everything.

my /etc/httpd/conf.d/phpmyadmin.conf file is:

<Directory "/usr/share/phpmyadmin">
   Order Deny,Allow
#   Deny from all
   Allow from 127.0.0.1
</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

I also used:

Allow from all

My /usr/share/phpmyadmin/config.inc.php is:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use scripts/setup.php
 *
 * All directives are explained in Documentation.html and on phpMyAdmin
 * wiki <http://wiki.phpmyadmin.net>.
 *
 * @version $Id$
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>

I also changed permissions to /var/www/ "755" and disabled SElinux.

Another thing i tried is use this at the beginning:

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

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

Every change i made i restarted also apache "sudo systemctl restart httpd.service" I tried everything but with no luck.I still get the error.Any ideas? Thank you!

Evangelos
  • 271
  • 1
  • 3
  • 13
  • Linux is case sensitive: `/usr/share/phpMyAdmin` vs `/usr/share/phpmyadmin`. – admirableadmin Aug 13 '15 at 08:43
  • follow this work for me http://stackoverflow.com/questions/23235363/forbidden-you-dont-have-permission-to-access-phpmyadmin-on-this-server BUT I NEED TO ALLOW FROM MORE THAN ONE IP ADDR, DID YOU FIND ANY SOLUTION? – rafaelphp Aug 14 '15 at 21:10

4 Answers4

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

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

Above code you mentioned worked for me

  • Just to point out - the other question linked in the comment also provides this answer as the workaround but please bear in mind the potential of opening up the db to all IPs. There are some other solutions mentioned - please read through. That being said - this did help me out so thanks :) – alpharomeo Sep 16 '20 at 20:44
2

Try like this:

I just had to replace the 127.0.0.1 IP with my IP and Viola!
So i guess just replacing the "Require ip 127.0.0.1" & "Require ip ::1" with "Require all granted" did the trick.

Himanth
  • 2,381
  • 3
  • 28
  • 41
Michael Kapp
  • 97
  • 3
  • 11
1

Open ssh.

Type the following code: nano /etc/httpd/conf.d/phpMyAdmin.conf

and replace from <Directory /usr/share/phpMyAdmin/> to </Directory>

with this code:

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

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

Enjoy :)

0

Don't install phpmyadmin with yum . it has lot of bugs to open, try to download from phpmyadmin official website and extract it to your /var/www/html directory and rename the folder to phpmyadmin and restart your httpd service. check now no worries at all.