phpmyadmin 403禁止访问

eni9jsuy  于 2022-11-09  发布在  PHP
关注(0)|答案(4)|浏览(211)

当我尝试在Centos 7上运行localhost/phpmyadmin时,出现权限错误:

Forbidden

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

我已经找遍了,做了所有的事。
/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/etc/

<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

我也习惯了:

Allow from all

我的/usr/source/config. php是:

<?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'] = '';

?>

我还将权限更改为/var/www/“755”并禁用了SElinux。
我尝试的另一件事是在开始时使用这个:

<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>

我所做的每一个改变,我也重新启动Apache“sudo systemctl重新启动httpd.service”我尝试了一切,但没有运气。我仍然得到错误。有什么想法吗?谢谢!

gkn4icbw

gkn4icbw1#

<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>

上面你提到的代码对我很有效

y3bcpkx1

y3bcpkx12#

试着这样做:
我只需要127.0.0.1用我的IP和Viola替换www.example.com的IP!
所以我想只要把“需要ip 127.0.0.1“和“需要ip::1”替换为“需要所有授权”就行了。

hivapdat

hivapdat3#

不要用yum安装phpmyadmin。它有很多bug要打开,试着从phpmyadmin官方网站下载并解压到你的/var/www/html目录下,并将文件夹重命名为phpmyadmin,然后重新启动你的httpd服务。

mrzz3bfm

mrzz3bfm4#

打开ssh。
键入以下代码:nano /etc/httpd/conf.d/phpMyAdmin.conf
并将<Directory /usr/share/phpMyAdmin/>替换为</Directory>
使用以下代码:

<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>

尽情享受吧:)

相关问题