403在AWS EC2实例上禁止访问phpmyadmin

时间:2016-09-29 14:42:05

标签: mysql amazon-web-services amazon-ec2 phpmyadmin http-status-code-403

我的/etc/httpd/conf.d/phpMyadmin.conf具有以下配置

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

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

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

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>

       Require ip xx.xx.xx.xxx
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow

    #Deny from All
     Allow from xx.xx.xx.xxx
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip xx.xx.xx.xxx
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     #Deny from All
     Allow from xx.xx.xx.xxx
     Allow from ::1
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    #Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    #Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    #Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

当我在我的页面EC2实例上访问时 http://xx.xx.xx.xxx/phpmyadmin,我发生了You don't have permission to access /phpmyadmin on this server.错误。 我确定了这个IP地址xx.xx.xx.xxx is my EC2's Elastic IP address。 phpMyadmin.conf有正确的xx.xx.xx.xxx允许。 我尝试按照thisthisthis的类似链接进行操作。 但仍然有错误。我的错误可能有什么问题? 我的EC2实例安装了AWS linux OS。

由于

2 个答案:

答案 0 :(得分:0)

根据我的理解,此配置与 PhpMyadmin 相关。要将此配置加载到Apache Web Server,请确保Apache正在加载conf.d中的所有配置文件,方法是查看httpd.conf如果您使用的是apache [Not Apache2]和apache2.conf [用于Apache2 ]

在/etc/apache2/apache2.conf中,您将找到以下行,其中包含这些文件:

# Include generic snippets of statements
Include conf.d/

[Refference]

您可能已经检查过它,这是解决方案之一。

答案 1 :(得分:0)

我有同样的错误。按照此链接https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html进行所有所有者和组更改。像上面一样完成所有操作,但是出现了该错误。最后,重新启动httpd之后,我就可以连接了。