自定义端口上的 VirtualHost 上的 Apache 2 和 phpmyadmin:您无权访问此服务器上的 /phpmyadmin

自定义端口上的 VirtualHost 上的 Apache 2 和 phpmyadmin:您无权访问此服务器上的 /phpmyadmin

我在 Google 上搜索了很多,但没有找到在自定义端口上的虚拟主机上设置 phpmyadmin 的指南。

Apache 2.4,这是我的 httpd-vhosts.conf

Listen 0.0.0.0:66

<VirtualHost *:66>
Alias /phpmyadmin /usr/local/apache2/phpmyadmin
<Directory "/usr/local/apache2/phpmyadmin">
    Options FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
    </IfModule>

</Directory>
# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
 <IfModule mod_authn_file.c>
 AuthType Basic
 AuthName "phpMyAdmin Setup"
 AuthUserFile /etc/phpmyadmin/htpasswd.setup
 </IfModule>
 Require valid-user
</Directory>
#Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
   Order Deny,Allow
   Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
  Order Deny,Allow
  Deny from All

这是日志中的错误

 [Thu Jul 05 17:45:49.322954 2012] [authz_core:error] [pid 14314:tid 139825756501760] [client 127.0.0.1:49262] AH01630: client denied by server configuration: /usr/local/apache2/phpmyadmin/

这些是特权

/usr/local/apache2# ls -l
insgesamt 60
drwxr-sr-x  2 root staff  4096  6. Jun 18:40 bin
drwxr-sr-x  2 root staff  4096  6. Jun 18:40 build
drwxr-sr-x  2 root staff  4096  6. Jun 18:40 cgi-bin
drwxr-sr-x  4 root staff  4096  5. Jul 17:04 conf
drwxr-sr-x  3 root staff  4096  6. Jun 18:40 error
drwxr-xr-x  2 root staff  4096  5. Jul 17:03 htdocs
drwxr-sr-x  3 root staff  4096  6. Jun 18:40 icons
drwxr-sr-x  2 root staff  4096  6. Jun 18:40 include
drwxr-sr-x  2 root staff  4096  5. Jul 17:44 logs
drwxr-sr-x  4 root staff  4096  6. Jun 18:40 man
drwxr-xr-x 14 root staff 12288  6. Jun 17:55 manual
drwxr-sr-x  2 root staff  4096 24. Jun 18:03 modules
drwxr-sr-x  8 root staff  4096  5. Jul 17:42 phpmyadmin

答案1

我不是 Apache 专家,但您/etc/httpd/conf/httpd.conf是否尝试过添加以下内容?

<Directory "/usr/local/apache2/phpmyadmin/">
Options All
AllowOverride All
Require all granted
</Directory>

Apache2 中有一个新的权限模型,其中默认如下:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

因此,您必须专门为目录添加例外。您可以阅读更多相关信息这里

相关内容