403 Error when accessing phpMyAdmin on an ec2 Inst

2019-04-17 00:38发布

问题:

I wanted to install a LAMP environment on a new EC2 instance using Amazon-Linux following amazon's tutorial. Then I wanted to have phpMyAdmin so I installed it using sudo yum --enablerepo=epel install phpmyadmin and created a link to the www directory sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin.

Then I altered the /etc/httpd/conf.d/phpMyAdmin.conf file to allow access.

The current file:

# 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

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

 Order allow,deny
 Allow from all
</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>

But still I'm getting a 403 error, when I try to access /phpMyAdmin

error_log:

[Thu Aug 27 13:45:47.702678 2015] [authz_core:error] [pid 25763] [client 37.49.61.176:59958] AH01630: client denied by server configuration: /usr/share/phpMyAdmin/
[Thu Aug 27 13:45:48.699611 2015] [authz_core:error] [pid 25763] [client 37.49.61.176:59958] AH01630: client denied by server configuration: /usr/share/phpMyAdmin/
[Thu Aug 27 13:49:22.181819 2015] [authz_core:error] [pid 25765] [client 37.49.61.176:60222] AH01630: client denied by server configuration: /usr/share/phpMyAdmin/

What else could be the error?

回答1:

The issue was fixed after I removed

Alias /phpMyAdmin /usr/share/phpMyAdmin

from

/etc/httpd/conf.d/phpMyAdmin.conf

And then don't forget to restart by using the following command

sudo service httpd restart


回答2:

Copy the following code in your /etc/httpd/conf.d/phpMyAdmin.conf

I found it here http://howsolve.com/i-always-get-a-403-error-with-phpmyadmin-ec2-aws/

    # 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

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

     Order allow,deny
     Allow from all
    </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>