2014-09-23 204 views
1

我不知道我在做什么错,但我不能用Apache更改我的本地主机文件的目录。我用httpd.conf尝试了各种各样的东西,包括将“Order allow,deny”更改为"Require all granted"。它仍然不起作用。我无所不在地在Apache上更改DocumentRoot无效

我运行Windows 7 64位,我试图让Apache的工作,但所有的解决方案到目前为止还没有帮我改变DocumentRoot的,由于错误403

这里是httpd.conf

这是因为最新的服务重新启动

The Apache2.4 service is restarting. The Apache2.4 service has restarted. m_winnt:notice [pid5304:tid 468] AH00424: Parent: Received restart signal -- Restarting the server. 
[Mon Sep 22 22:37:25.315061 2014] [ssl:warn] [pid 5304:tid 468] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name 
[Mon Sep 22 22:37:25.315061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00455: Apache/2.4.10 (Win32) OpenSSL/1.0.1h configured -- resuming normal operations 
[Mon Sep 22 22:37:25.315061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00456: Apache Haus VC9 Server built: Jul 15 2014 20:34:18 
[Mon Sep 22 22:37:25.315061 2014] [core:notice] [pid 5304:tid 468] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24' 
[Mon Sep 22 22:37:25.317061 2014] [mpm_winnt:notice] [pid 5304:tid 468] AH00418: Parent: Created child process 3648 
[Mon Sep 22 22:37:26.075104 2014] [ssl:warn] [pid 3648:tid 344] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name 
[Mon Sep 22 22:37:26.265115 2014] [mpm_winnt:notice] [pid 6612:tid 348] AH00364: Child: All worker threads have exited. 
[Mon Sep 22 22:37:26.372121 2014] [ssl:warn] [pid 3648:tid 344] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name 
[Mon Sep 22 22:37:26.375121 2014] [mpm_winnt:notice] [pid 3648:tid 344] AH00354: Child: Starting 64 worker threads. 
[Mon Sep 22 22:43:06.157556 2014] [autoindex:error] [pid 3648:tid 1052] [client ::1:53336] AH01276: Cannot serve directory C:/Apache24/htdocs/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive 
+0

我每次保存的httpd,我的httpd -k重启。我可以告诉重新启动工程,因为我可以使用它在默认的DocumentRoot目录和自定义的DocumentRoot目录之间切换。自定义总是导致403错误。 – poetryrocksalot 2014-09-23 05:24:25

+0

我不认为我有任何.htaccess文件(我无法在任何地方找到它)。我不确定webroot是什么。 conf已上传。 – poetryrocksalot 2014-09-23 05:33:30

+0

是的,我将包含我的index.html的文件夹命名为“localhost”。它位于“C:\”中。我不确定这是不是一个好主意。 – poetryrocksalot 2014-09-23 05:39:56

回答

1

我的错误日志中这样的配置应该工作:

DocumentRoot "C:/www" 
<Directory "C:/www"> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory> 

不要忘记在对httpd.conf文件进行任何更改后重新启动服务器。我也会尝试暂时删除位于C:/www文件夹中的任何现有.htaccess文件。

要检查您的配置文件的语法是否正确使用-t选项:

httpd -t 

您还可以检查logs/error.log拿到什么地方出了错一个更好的描述。

参考

Installing Apache 2.2 on Microsoft Windows

+0

这是我从中得到的错误: 无效的命令'订单',可能是拼写错误或由未包含在服务器配置中的模块定义 – poetryrocksalot 2014-09-23 06:18:12

+0

尝试删除当前配置文件并复制原始文件(不知道位置这在Windows上)虽然)到相同的位置,然后添加上述指令(更改www到本地主机),保存该文件,然后重新启动您的服务器。 – Cyclonecode 2014-09-23 06:21:47

+0

不起作用。我的目录是否必须在我的Apache安装中? – poetryrocksalot 2014-09-23 06:26:29

0

首先修改httpd.conf文件

DocumentRoot "c:/www" 
<Directory "c:/www"> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 

然后打开 “\的conf \额外\的httpd-vhosts.conf” 文件。

<VirtualHost *:80> 
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com" 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot "C:\www" 
</VirtualHost> 

最后重新启动Apache Web服务器,你是好去..