繁体   English   中英

新的 xampp 安全概念:访问禁止错误 403 - Windows 7 - phpMyAdmin

[英]New xampp security concept: Access Forbidden Error 403 - Windows 7 - phpMyAdmin

我已经在 Windows 7 Ultimate 上下载并安装了适用于 Windows 的 XAMPP 1.8.1。 我已按照这些说明将 XAMPP 设置为与 IIS 一起运行

到目前为止一切都很好,我的 PHP 站点在本地运行,除了 phpMyAdmin 之外的所有内容都可以从 XAMPP 菜单中找到。

但是,当我尝试访问 phpMyAdmin 时出现此错误:

禁止访问!

新的 XAMPP 安全概念:

只能从本地网络访问请求的目录。

此设置可以在文件“httpd-xampp.conf”中配置。

我通过谷歌找到了几个答案,在这个网站上找到了一些答案。 但是,到目前为止,我尝试过的所有解决方案都没有解决该问题。

这是我的 httpd-xampp.conf 文件:

#
# XAMPP settings
#

<IfModule env_module>
    SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
    SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
    SetEnv PHPRC "\\xampp\\php"
    SetEnv TMP "\\xampp\\tmp"
</IfModule>

#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php5ts.dll"
LoadModule php5_module "C:/xampp/php/php5apache2_4.dll"

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
#    SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>


<IfModule php5_module>
    PHPINIDir "C:/xampp/php"
</IfModule>

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
          Require all granted
    </Files>
</Directory>

<Directory "C:/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/xampp/htdocs/xampp">
    <IfModule php5_module>
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /security "C:/xampp/security/htdocs/"
    <Directory "C:/xampp/security/htdocs">
        <IfModule php5_module>
            <Files "xamppsecurity.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
        Require all granted
   </Directory>

    Alias /licenses "C:/xampp/licenses/"
    <Directory "C:/xampp/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
        Require all granted
   </Directory>

    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig Limit
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
        <IfModule php5_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
        Require all granted
    </Directory>
</IfModule>

#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Allow from all
    Require all granted

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

有没有人知道我错过了什么?

您所要做的就是编辑 httpd-xampp.conf

Require localRequire all在 LocationMatch 标记中授予的权限

就是这样!

在新 Xampp

您所要做的就是编辑文件:

C:\\xampp\\apache\\conf\\extra\\httpd-xampp.conf

并转到如下所示的目录标签:

<目录“C:/xampp/phpMyAdmin”>

然后改变

需要本地

要求所有授予

在目录标签中。

重新启动 Xampp。 就是这样!

要求所有授予对我来说似乎有点远。 查看我使用的文档: Require ip 192.168 to allow all internal access。

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Require local
    Require ip 192.168
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
    <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">

        Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

祝你好运!!!!

尝试重新安装新版本的 XAMPP。 找到“ <Directory "C:/xampp/php"> ”然后改成这样

<Directory "C:/xampp/php">
    AllowOverride AuthConfig Limit
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

XAMPP 7.3.*更新

如果您在最新的 XAMPP 中遇到与phpmyadmin相同的问题,就像我一样。

解决方案写在位于[XAMPP IP]/dashboard/docs/access-phpmyadmin-remotely.html的官方文档中

要允许从其他主机远程访问 phpMyAdmin,请按照下列步骤操作:

  1. 通过双击安装的磁盘映像中的 XAMPP 图标启动堆栈管理器。
  1. 确保 Apache 和 MySQL 服务正在堆栈管理器的“服务”选项卡中运行(或根据需要启动它们)。
  1. 从堆栈管理器的“常规”选项卡中打开一个新终端。
  1. 编辑 /opt/lampp/etc/extra/httpd-xampp.conf 文件。
  1. 在这个文件中,找到块<Directory "/opt/lampp/phpmyadmin">

更新此块并将Require local替换为Require all granted

  1. 保存文件并使用堆栈管理器重新启动 Apache 服务。

第 (4) 节注意事项要编辑此文件,请确保已安装vim

如果您的计算机连接到网络,则第 (5) 节的注意事项而不是允许访问所有人,这是非常不安全的。 一种更安全的方法是限制对@Gunnar Bernstein 建议的仅一组 IP 的访问。

就我而言,我做了:

<Directory "/opt/lampp/phpmyadmin">
  AllowOverride AuthConfig Limit
  Require local
  Require ip 192.168
  ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>

您必须编辑 2 个文件 - 1. httpd-vhosts.conf & 2. httpd-xampp.conf

注意:确保您备份文件 (httpd-xampp.conf) 和 (httpd-vhosts.conf),这两个文件都位于 Drive:\\xampp\\apache\\conf\\extra

打开 httpd-vhosts.conf 文件并在文件底部更改它

<VirtualHost *:80>
DocumentRoot “E:/xampp/htdocs/”
ServerName localhost
<Directory E:/xampp/htdocs/>.
Require all granted 
</Directory>
</VirtualHost>

这里 E:/xampp 是我的项目工作区,您可以根据您的设置进行更改

第二次更改位于 httpd-xampp.conf 文件中,并在文件底部更改它

#
# New XAMPP security concept
#
<LocationMatch “^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))”>
Order deny,allow
Allow from all
Allow from ::1 127.0.0.0/8
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

注释掉 httpd-xampp.conf 中的 Require local 行。
重新启动阿帕奇。
为我工作,将我的手机连接到我 PC 上的测试网站。 不知道安全隐患。

要访问本地网络以外的请求目录,您需要更改文件“httpd-xampp.conf”中配置的XAMPP security concept

  • 文件位置xampp\\apache\\conf\\extra\\httpd-xampp.conf

Require Directive选择哪些经过身份验证的用户可以访问资源

语法 « Require entity-name [entity-name] ...

来自« XAMPP 安全概念只允许本地环境 -需要本地

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        Require local
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

« XAMPP 安全概念允许任何环境 -要求所有授予

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>

禁止访问! 来自 HTML 页面的消息。

在此处输入图片说明


允许指令控制哪些主机可以访问服务器的某个区域

语法 « Allow from all|host|env=[!]env-variable [host|env=[!]env-variable] ...

只允许本地环境。 使用以下任何指定的 url。

  • http://localhost/phpmyadmin/
  • http://127.0.0.1/phpmyadmin/

     <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 \\ ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </LocationMatch>

只允许指定的IPv4IPv6地址空间。

  • IPv4 的链路本地地址在地址块 169.254.0.0/16 中以 CIDR 表示法定义。 在 IPv6 中,它们被分配了地址块fe80::/10
  • 唯一本地地址 (ULA) 是块fc00::/7的 IPv6 地址

    <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>

允许任何网络地址 所有人都允许

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Allow from all

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

404 - XAMPP控制面板:无法启动 Apache HTTP 服务器

URL: http://localhost/xampp/index.php

Error « 
    Not Found
    HTTP Error 404. The requested resource is not found.

所需的默认 Apache HTTP 服务器端口 80 实际被其他服务使用。

  • 您需要找到运行在80端口的服务并停止该服务,然后启动Apache HTTP服务器。

    使用Netstat显示活动的 TCP 连接、计算机正在侦听的端口。

     C:\\Users\\yashwanth.m>netstat -ano Active Connections Proto Local Address Foreign Address State PID TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 2920 TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1124 TCP 127.0.0.1:5354 0.0.0.0:0 LISTENING 3340 TCP [::]:80 [::]:0 LISTENING 2920 C:\\Users\\yashwanth.m>netstat -ano |findstr 2920 TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 2920 TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 2920 TCP [::]:80 [::]:0 LISTENING 2920 TCP [::]:443 [::]:0 LISTENING 2920 C:\\Users\\yashwanth.m>taskkill /pid 2920 /F SUCCESS: The process with PID 2920 has been terminated.
  • 从主 Apache HTTP 服务器配置文件D:\\xampp\\apache\\conf\\httpd.conf更改侦听端口。 例如: 81 Listen 80Listen 81 ,访问 URL 将是http://localhost:81/xampp/index.php

     # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 0.0.0.0:80 #Listen [::]:80 Listen 80

有关httpd and virtual host on XAMPP更多信息

只需删除:

Alias /phpmyadmin "C:/xampp2/phpMyAdmin/"
<Directory "C:/xampp2/phpMyAdmin">
    AllowOverride AuthConfig
    Require all granted
</Directory>

并从以下位置删除 phpmyadmin:

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

一些答案是正确的,但如果使用新的 xampp 或其他答案不起作用,请尝试以下操作:

只需转到 xampp 文件夹:

xampp/apache/conf/extra/httpd-xampp.conf

如果您尝试从网络中的本地 IP 访问,请进行更改,

 Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

改成 :

 Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Require all granted
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

注意:这只是针对文本,为了 xampp 的安全性有一些搜索....

在您的 xampppath\\apache\\conf\\extra 打开文件 httpd-xampp.conf 并找到以下标签:

<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
Order deny,allow
Deny from all
Allow from ::1 127.0.0.0/8 
ErrorDocument 403   /error/HTTP_XAMPP_FORBIDDEN.html.var   

并在Allow from ::1 127.0.0.0/8 {line}之后添加Allow from all

重新启动 xampp,你就完成了。

如果您使用的是使用“Bitnami”安装程序构建的较新的 XAMPP(例如 PHP 5.6、7)并且它包含 Apache 2.4.x,那么这适用:

https://httpd.apache.org/docs/2.4/upgrading.html#run-time

2.2 配置:

Order allow,deny
Allow from all

2.4 配置:

Require all granted

如果您有任何自定义虚拟主机定义,这也适用于 VirtualHost 部分。

Ubuntu (Linux)

:- $ sudo gedit /opt/lampp/etc/extra/httpd-xampp.conf

 Comment "Deny from all" in the following section,

更改文件

# New XAMPP security concept # <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> Order deny,allow #Deny from all #Require local 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

对于许多人来说,这是一个许可问题,但对我来说,结果证明错误是由我试图提交的表单中的错误引起的。 具体来说,我不小心在“action”的值后面加上了“>”符号。 所以我建议你再看看你的代码

我尝试了一切,但没有任何效果。 所以我只是使用:chmod -R 777 到 htdocs。 至少它只在我的本地。

一个原因也可能是Skype! 如果您使用默认的 XAMPP 设置,它们都将在同一个端口 (80) 上运行。 你可以:

  • 关闭 Skype
  • 更改 XAMPP 端口

G:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf

#start block
NameVirtualHost *:80

<VirtualHost *:80>
   ServerName localhost
   #change your directory name
   DocumentRoot "G:\xampp\htdocs"
</VirtualHost>

#Your vertual Host
<VirtualHost *:80>
    DocumentRoot "G:/xampp/htdocs/dev2018/guessbook"
    ServerName dev.foreign-recruitment
    <Directory "G:/xampp/htdocs/dev2018/guessbook/">

    </Directory>
</VirtualHost>
#end block

这可能是因为配置错误,特别是如果您的其他站点工作正常。

<VirtualHost cmsdemo.git:88>
    DocumentRoot "C:/Projects/rwp/"
    ServerName cmsdemo.git
    <Directory C:/Projects/cmsdemo/>
        Require all granted 
        AllowOverride All
    </Directory>
</VirtualHost>

请注意,我在DocumentRoot 中指定了一个文件夹,在Directory 中,我指定了另一个文件夹,因此出现了 403 错误。 这解决了我的问题。

对于使用 Windows 使用 xampp 和 IIS 时遇到问题的任何人,

检查 apache 上的 xamp 面板哪个端口正在使用

假设 apache 正在使用端口81然后试试这个

http://127.0.0.1:81/

对我来说就像魅力一样工作,它可能会在未来帮助某人

对于 Windows 10,这些选项对我不起作用。

在没有理解关于用户帐户控制 (UAC) 的初始警告的情况下重新安装多次后,它可以通过以下步骤工作:

  • 将 C:\\xampp 重命名为 C:\\xampp_old,
  • 手动创建 C:\\xampp 文件夹
  • 在 C:\\xampp 中重新安装 XAMPP
  • 将您的应用程序(如果已配置)移动到新的安装文件夹。

现在,如果您愿意,可以删除 C:\\xampp_old。 我试图在我的桌面文件夹中安装 XAMPP,但它失败了,因为我的 Windows 用户包含一个空格字符并且 Apache 无法运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM