Debian

自定義埠上 VirtualHost 上的 Apache 2 和 phpmyadmin:您無權訪問此伺服器上的 /phpmyadmin

  • February 11, 2014

我搜尋了很多,但沒有找到在自定義埠上的虛擬主機上設置 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

我不是 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>

所以你必須專門為你的目錄添加例外。你可以在這裡閱讀更多關於它的資訊

引用自:https://serverfault.com/questions/405088