2014-09-23 206 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服務器,你是好去..