2012-10-19 137 views
4

我試圖設置Xampp進行家庭開發。它的安裝正確,我可以訪問像演示,安全,狀態等xampp頁面,甚至使用phytin-gui來啓動和停止服務器。Xampp:我無法從本地主機訪問phpMyAdmin

但是,當涉及使用訪問phpMyAdmin的「http://localhost/phpmyadmin」我得到了一個錯誤:

Access forbidden! 

New XAMPP security concept: 

Access to the requested directory is only available from the local network. 

This setting can be configured in the file "httpd-xampp.conf". 

我檢查了我的httpd-xampp.conf,似乎是正確的。我試圖改變拒絕所有的允許所有,但沒有工作。

我的主機文件指向localhost到127.0.0.1,這是預計訪問所有xampp文件。

我乳寧XAMPP 1.8.1在Ubuntu 12.04機器

有人說有同樣的問題?我失去了2個小時的谷歌搜索,但所有我發現的是,當試圖從其他網絡或機器訪問服務器時發生此錯誤。但對我來說,情況是我直接在服務器上工作,所以它假設我可以訪問phpMyAdmin作爲默認值。

我的httpd-xampp.conf

# 
# New XAMPP security concept 
# 
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> 
    Order deny,allow 
    Deny from all 
    Allow from ::1 127.0.0.0/8 \ 
     fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \ 
     fe80::/10 169.254.0.0/16 

    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var 
</LocationMatch> 
+0

看: http://stackoverflow.com/a/16617319/2395363 – Andy

回答

5

轉到/opt/lampp/etc/extra目錄中的情況下,你已經/opt下安裝了XAMPP,並編輯httpd-xampp.conf添加Require all granted,如下圖所示:

# since XAMPP 1.4.3 
<Directory "/opt/lampp/phpmyadmin"> 
    AllowOverride AuthConfig Limit 
    Order allow,deny 
    Allow from all 
    Require all granted 
</Directory> 

你可能有通過運行/opt/lampp/lampp restart來重新啓動LAMPP服務器。

+1

這不只是禁用一個黑客**所有** phpmyadmin路徑的安全性?錯誤的真正原因是什麼? ref:[Require Directive](http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require)'要求所有授予的 無條件地允許訪問。' – 2013-05-13 09:10:40

+0

您正確地指出解決方案以上授予無條件訪問權限。 **原因**:127.0.0.1只能訪問安全文件夾並拒絕來自LAN的訪問。 **若要解決**問題並在某種程度上維護安全性,您可以在代碼
下嘗試'Allow from xxx.xxx.x.xxx xxx.xxx.x.xxx',如果您想要將多個IP地址添加到從規則中允許,只需在最後一行之後添加一個空格,或者使用反斜槓「\」結束一行,並且可以直接在下一行寫入。 –

2

我也在XAMPP自己的論壇中發現了這個問題。提到Require all granted答案,但是無條件授予訪問權限。螺紋繼續提供a better solution

Just update your httpd-xampp.conf. Replace the End with:

# 
# New XAMPP security concept 
# 
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> 
    <RequireAny> 
     Require ip ::1 127.0.0.0/8 \ 
     fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \ 
     fe80::/10 169.254.0.0/16 
    </RequireAny> 
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var 
</LocationMatch> 

Then restart your lampp with: sudo /opt/lampp/lampp restart

裁判:http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require

0

我通過創建phpmyadmin

一個新的虛擬主機解決了這個附加以下到C:/xampp/apache/conf/httpd.conf

NameVirtualHost phpmyadmin.local 

<VirtualHost phpmyadmin.local> 
    ServerName phpmyadmin.local 
    DocumentRoot "C:/xampp/htdocs/phpmyadmin" 
    <Directory "C:/xampp/htdocs/phpmyadmin"> 
    AllowOverride All 
    Allow from All 
    </Directory> 
</VirtualHost> 

DocumentRoot/Directory更改爲您安裝了版本的路徑10。

打開C:\Windows\System32\drivers\etc\hosts文件在文本編輯器,並添加以下行:

127.0.0.1  phpmyadmin.local 

然後保存hosts文件並重新啓動xampp

https://stackoverflow.com/a/16617319/2395363

0

這適用於1.8.2 XAMPP答案[PHP:25年5月4日]

只要把#號之前需要本地之下,而且重要的是,停在XAMPP控制面板啓動Apache。這就是它,它肯定在我的答案本主題工作

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> 
     #Require local 

    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var 
</LocationMatch>