Назад | Перейти на главную страницу

Доступ к CentOS 6 phpMyAdmin запрещен

У меня возникли проблемы с настройкой моего VPS с помощью phpMyAdmin.

Мое сообщение об ошибке:

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

Моя конфигурация phpMyAdmin:

    # 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 127.0.0.1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from All
     Allow from 127.0.0.1
  </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.01
     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
</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>

У меня был 127.0.0.1 на моем публичном IP-адресе, но он все еще не работал

Также урок, за которым я следил: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-a-centos-6-4-vps

Заранее спасибо!

Require ip 127.0.0.1

неверно в вашем контексте. Если ограничить доступ к каталогу phpMyAdmin только для localhost, только локальный клиент (скажем, из командной строки или firefox, запущенный на локальном дисплее) получит доступ к этому каталогу. Если вы используете этот сервер на VPS, скорее всего, вы хотите быть менее строгим, например, предоставить доступ к вашему домашнему IP-адресу (скорее всего, маршрутизатору NAT) или месту, откуда вы получаете доступ к своему VPS.

Большинство людей будет защищать свой доступ к phpmyadmin, разрешив его только через защищенную ssl ссылку (см. https://wiki.apache.org/httpd/NameBasedSSLVHosts например), то установите менее строгие ограничения для каталога, например:

Require group admin

или даже отказаться от аутентификации Apache с помощью

Require all granted

поскольку phpMyAdmin возьмет на себя свою собственную аутентификацию на основе mysql.

Часть конфигурации phpMyAdmin будет выглядеть примерно так:

<IfModule mod_ssl.c>
     <VirtualHost _default_:443>
        SSLEngine on
       #   SSLCertificateFile directive is needed. Note that you'd better do with creating your own 
       # private certificates (see any openssl tutorial) and point at them here
       SSLCertificateFile   /etc/ssl/certs/ssl-cert-snakeoil.pem
       SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

     # additional trick: many robots try to access paths variants to myurl/phpmyadmin
     # a minor trick is to choose an entirely different alias to avoir their clogging your logs 
     # with many break in attempts.

        Alias /mysqladmin /my/path/to/phpmyadmin
        <Directory "/my/path/to/phpmyadmin">
        Options Indexes FollowSymLinks MultiViews
            AllowOverride All
        Require all granted
        </Directory>