添加 VirtualHost 失败:访问禁止错误 403 (XAMPP) (Windows 7)

发布于 2025-01-02 08:03:16 字数 1869 浏览 2 评论 0 原文

我在 Windows 7 上运行了 XAMPP 安装。

一旦我将 VirtualHost 添加到 httpd-vhosts.conf,“常规”http://localhost 和新的 dropbox .local 不起作用。

这是我添加到我的 httpd-vhosts.conf 中的内容:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ServerAlias www.dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>

所以我查找了我的 dropbox.local-error.log 以获取任何信息:

[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

此错误似乎可以通过以下方式解决 :添加

<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
     Allow from all
</directory>

但现在我在 dropbox.local-error.log 中收到此错误:

[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

此外,当我尝试访问 http://localhost 时,我在常规中没有收到任何错误error.log,虽然我得到了当我尝试访问它时出现错误403

任何人都可以帮忙吗...这让我发疯:S

编辑: 另外在 httpd.conf 中有以下内容(我已经多次看到它被提及,所以在有人说它之前):

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

I've got a XAMPP installation running on Windows 7.

As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.

This is what I added to my httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ServerAlias www.dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>

So I looked up my dropbox.local-error.log for any information:

[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

This error seems to be solved by adding

<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
     Allow from all
</directory>

But now I get this error in dropbox.local-error.log:

[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.

Can anybody help... It's driving me mad :S

EDIT:
Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

滥情空心 2025-01-09 08:03:16

好的:这就是我现在所做的,它已经解决了:

我的 httpd-vhosts.conf 现在看起来像这样:

<VirtualHost dropbox.local:80>
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
    <Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
        # AllowOverride All      # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all         # Deprecated

        # --New way of doing it
        Require all granted    
    </Directory>
</VirtualHost>

首先,我发现有必要设置 ; 选项。所以我把; [..] - 内的部分[..]
之后,我将 AllowOverride AuthConfig Indexes 添加到 选项中。

现在,http://localhost 也指向 dropbox-virtualhost。因此,我将 dropbox.local 添加到 中,使其成为

最终它有效:D!

我是一个快乐的人! :) :)

我希望其他人可以使用此信息。

Okay: This is what I did now and it's solved:

My httpd-vhosts.conf looks like this now:

<VirtualHost dropbox.local:80>
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
    <Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
        # AllowOverride All      # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all         # Deprecated

        # --New way of doing it
        Require all granted    
    </Directory>
</VirtualHost>

First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory>-part INSIDE the <VirtualHost > [..] </VirtualHost>.
After that, I added AllowOverride AuthConfig Indexes to the <Directory> options.

Now http://localhost also points to the dropbox-virtualhost. So I added dropbox.local to <VirtualHost *:80> which makes it as <VirtualHost dropbox.local:80>

FINALLY it works :D!

I'm a happy man! :) :)

I hope someone else can use this information.

送舟行 2025-01-09 08:03:16

对我来说,当我将“目录”内容更改为:

<Directory  "*YourLocation*">
Options All
AllowOverride All
Require all granted  
</Directory>

For me worked when I changed "directory" content into this:

<Directory  "*YourLocation*">
Options All
AllowOverride All
Require all granted  
</Directory>
爱人如己 2025-01-09 08:03:16

对于我(以及 Windows 7 上的 XAMPP)来说,这就是有效的:

<Directory "C:\projects\myfolder\htdocs">`
   AllowOverride All
   Require all granted
   Options Indexes FollowSymLinks
</Directory>` 

正是这一行会导致 403:

Order allow,deny

For me (also XAMPP on Windows 7), this is what worked:

<Directory "C:\projects\myfolder\htdocs">`
   AllowOverride All
   Require all granted
   Options Indexes FollowSymLinks
</Directory>` 

It is this line that would cause the 403:

Order allow,deny
逆光下的微笑 2025-01-09 08:03:16

我在 Windows 7 上使用 XAMPP 1.6.7。 这篇文章对我有用。

我在 C:/xampp/apache/conf/extrahttpd-vhosts.conf 文件中添加了以下几行。
我还取消了注释行 # NameVirtualHost *:80

<VirtualHost mysite.dev:80>
    DocumentRoot "C:/xampp/htdocs/mysite"
    ServerName mysite.dev
    ServerAlias mysite.dev
    <Directory "C:/xampp/htdocs/mysite">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

重新启动 apache 后,它仍然无法工作。
然后我必须按照文章中提到的步骤 9 编辑文件 C:/Windows/System32/drivers/etc/hosts

# localhost name resolution is handled within DNS itself.
     127.0.0.1       localhost
     ::1             localhost
     127.0.0.1       mysite.dev  

然后我开始工作http://mysite.dev

I'm using XAMPP 1.6.7 on Windows 7. This article worked for me.

I added the following lines in the file httpd-vhosts.conf at C:/xampp/apache/conf/extra.
I had also uncommented the line # NameVirtualHost *:80

<VirtualHost mysite.dev:80>
    DocumentRoot "C:/xampp/htdocs/mysite"
    ServerName mysite.dev
    ServerAlias mysite.dev
    <Directory "C:/xampp/htdocs/mysite">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

After restarting the apache, it were still not working.
Then I had to follow the step 9 mentioned in the article by editing the file C:/Windows/System32/drivers/etc/hosts.

# localhost name resolution is handled within DNS itself.
     127.0.0.1       localhost
     ::1             localhost
     127.0.0.1       mysite.dev  

Then I got working http://mysite.dev

暮色兮凉城 2025-01-09 08:03:16

谢谢你,成功了!但我

AllowOverride AuthConfig Indexes

用那个

AllowOverride All

替换了这个否则,.htaccess 不起作用:我遇到了 RewriteEngine 问题和错误消息“此处不允许 RewriteEngine”。

Thank you, that worked! But I replaced this

AllowOverride AuthConfig Indexes

with that

AllowOverride All

Otherwise, the .htaccess didn't work: I got problems with the RewriteEngine and the error message "RewriteEngine not allowed here".

眸中客 2025-01-09 08:03:16

以上建议对我不起作用。我让它在我的 Windows 上运行,灵感来自
http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html

对于httpd-vhosts.conf中的Http

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

对于在httpd-ssl.conf中使用Https(开放SSL)

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

希望它可以帮助别人!

Above suggestions didn't worked for me. I got it running on my windows, using inspiration from
http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html

For Http inside httpd-vhosts.conf

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

For using Https (Open SSL) inside httpd-ssl.conf

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

Hope it helps someone !!

只涨不跌 2025-01-09 08:03:16

经过这么多的改变、尝试和答案。
为了

SO: Windows 7 / Windows 10

Xampp 版本: Xampp 或 Xampp 便携式 7.1.18 / 7.3.7(控制面板 v3.2.4)

安装程序: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer

  1. 不要编辑其他文件,例如 httpd-xampp

  2. 停止 Apache

  3. 打开位于 **your_xampp_directory**\apache\conf\extra\httpd-vhosts.conf (默认情况下,您的 XAMPP 目录可能是:C:/xampp/htdocs)

  4. 删除以下行之前的哈希值(大约第 20 行):NameVirtualHost *:80(这可能是可选的)

  5. 考虑到您的目录路径,在文件末尾添加以下虚拟主机:

    <前><代码>##127.0.0.1
    <虚拟主机 *:80>
    文档根目录“C:/xampp/htdocs”
    服务器名称 localhost
    错误日志“logs/localhost-error.log”
    CustomLog“logs/localhost-access.log”常见

    ##127.0.0.2
    <虚拟主机 *:80>
    文档根目录“F:/myapp/htdocs/”
    服务器名称 test1.localhost
    服务器别名 www.test1.localhost
    错误日志“logs/myapp-error.log”
    CustomLog“logs/myapp-access.log”常见
    <目录“F:/myapp/htdocs/”>
    #全部选项 # 已弃用
    #AllowOverride All # 已弃用
    要求全部授予

  6. 编辑(具有管理员访问权限)您的主机文件(位于Windows\System32\drivers\etc< /code>,但使用以下提示,每个域只有一个环回 IP


    <前><代码>127.0.0.1 本地主机
    127.0.0.2 test1.localhost
    127.0.0.2 www.test1.localhost

对于每个实例,重复第二个块,第一个块是仅用于“默认”目的的主块。

After so many changes and tries and answers.
For

SOs: Windows 7 / Windows 10

Xampp Version: Xampp or Xampp portable 7.1.18 / 7.3.7 (control panel v3.2.4)

Installers: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer

  1. Do not edit other files like httpd-xampp

  2. Stop Apache

  3. Open httpd-vhosts.conf located in **your_xampp_directory**\apache\conf\extra\ (your XAMPP directory might be by default: C:/xampp/htdocs)

  4. Remove hash before the following line (aprox. line 20): NameVirtualHost *:80 (this might be optional)

  5. Add the following virtual hosts at the end of the file, considering your directories paths:

    ##127.0.0.1
    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost
        ErrorLog "logs/localhost-error.log"
        CustomLog "logs/localhost-access.log" common
    </VirtualHost>
    
    ##127.0.0.2
    <VirtualHost *:80>
        DocumentRoot "F:/myapp/htdocs/"
        ServerName test1.localhost
        ServerAlias www.test1.localhost
        ErrorLog "logs/myapp-error.log"
        CustomLog "logs/myapp-access.log" common
        <Directory  "F:/myapp/htdocs/">
            #Options All # Deprecated
            #AllowOverride All # Deprecated
            Require all granted  
        </Directory>
    </VirtualHost>
    
  6. Edit (with admin access) your host file (located at Windows\System32\drivers\etc, but with the following tip, only one loopback ip for every domain:

    127.0.0.1 localhost
    127.0.0.2 test1.localhost
    127.0.0.2 www.test1.localhost
    

For every instance, repeat the second block, the first one is the main block only for "default" purposes.

如此安好 2025-01-09 08:03:16

我正在使用 xampp 1.7.3。使用这里的灵感:xampp 1.7.3 升级损坏的虚拟禁止主机访问

代替添加 ; .. httpd-vhosts.conf 中的 ,我将其添加到 httpd.conf 中/xampplite/cgi-bin"> ..

这是我在 httpd.conf 中添加的内容:

<Directory "D:/CofeeShop">
    AllowOverride All
    Options  All
    Order allow,deny
    Allow from all
</Directory>

这是我在 httpd-vhosts.conf 中添加的内容

<VirtualHost *:8001>
    ServerAdmin [email protected]
    DocumentRoot "D:/CofeeShop"
    ServerName localhost:8001
</VirtualHost>

我还在 httpd.conf 中添加了 Listen 8001 来完成我的设置。

希望有帮助

I am using xampp 1.7.3. Using inspiration from here: xampp 1.7.3 upgrade broken virtual hosts access forbidden

INSTEAD OF add <Directory> .. </Directory> in httpd-vhosts.conf, I add it in httpd.conf right after <Directory "D:/xampplite/cgi-bin"> .. </Directory>.

Here is what I add in httpd.conf:

<Directory "D:/CofeeShop">
    AllowOverride All
    Options  All
    Order allow,deny
    Allow from all
</Directory>

And here is what I add in httpd-vhosts.conf

<VirtualHost *:8001>
    ServerAdmin [email protected]
    DocumentRoot "D:/CofeeShop"
    ServerName localhost:8001
</VirtualHost>

I also add Listen 8001 in httpd.conf to complete my setting.

Hope it helps

ま柒月 2025-01-09 08:03:16

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

For many it's a permission issue, but for me it turns out the error was brought about by a mistake in the form I was trying to submit. To be specific i had accidentally put a "greater than" sign after the value of "action". So I would suggest you take a second look at your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文