172

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

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

这是我添加到我的httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin postmaster@dummy-host.localhost
    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,尽管error 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>
4

9 回答 9

355

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

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>

首先,我看到有必要设置<Directory xx:xx>选项。所以我把<Directory > [..] </Directory>-part放在<VirtualHost > [..] </VirtualHost>. 之后,我添加AllowOverride AuthConfig Indexes<Directory>选项。

现在http://localhost还指向 dropbox-virtualhost。所以我添加dropbox.local<VirtualHost *:80>which 使它成为<VirtualHost dropbox.local:80>

最后它起作用了:D!

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

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

于 2012-02-02T18:32:43.600 回答
63

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

<Directory  "*YourLocation*">
Options All
AllowOverride All
Require all granted  
</Directory>
于 2012-10-15T12:34:40.783 回答
11

对我来说(也是 Windows 7 上的 XAMPP),这是有效的:

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

正是这条线会导致 403:

Order allow,deny
于 2013-03-14T14:44:08.097 回答
9

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

httpd-vhosts.conf我在文件中添加了以下行C:/xampp/apache/conf/extra
我也取消了该行的注释# 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

于 2013-08-02T07:13:20.440 回答
6

谢谢,这有效!但我换了这个

AllowOverride AuthConfig Indexes

接着就,随即

AllowOverride All

否则,.htaccess 不起作用:我遇到了 RewriteEngine 问题和错误消息“RewriteEngine not allowed here”。

于 2012-10-11T08:45:55.740 回答
4

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

对于 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 (Open SSL)

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

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

希望它可以帮助某人!

于 2014-11-01T12:52:42.470 回答
3

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

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. 停止阿帕奇

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

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

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

    ##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. 编辑(具有管理员访问权限)您的主机文件(位于Windows\System32\drivers\etc,但使用以下提示,每个域只有一个环回 ip

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

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

于 2019-02-28T16:00:12.193 回答
1

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

代替添加httpd-vhosts.conf,我将其添加<Directory> .. </Directory>httpd.conf之后。<Directory "D:/xampplite/cgi-bin"> .. </Directory>

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

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

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

<VirtualHost *:8001>
    ServerAdmin postmaster@dummy-host2.localhost
    DocumentRoot "D:/CofeeShop"
    ServerName localhost:8001
</VirtualHost>

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

希望能帮助到你

于 2015-07-18T21:25:56.630 回答
1

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

于 2016-04-21T11:34:34.167 回答