2013-01-08 77 views
0

我已經研究了約2個小時以上,包括1個小時的準備這份報告(我必須是一個慢速的工人,考慮到我沒有睡過24小時:-P)Apache>設置服務器端包括> OSX Snow Leopard>仍然不工作

虛擬服務器端包含Dreamweaver中的作品(圖像呈現除外),但在瀏覽到網頁時不起作用。

<!--#include virtual="/partialHtml/businessResult.shtml" -->

我意識到,我已經覆蓋了太多的配置設置(如果有一個更簡單,更優雅的方式,或許只是使用.htaccess文件~/Sites/mysite.com/那麼也請您評論);-)

從頂部(1)sudo nano /etc/apache2/httpd.conf

# 
# Filters allow you to process content before it is sent to the client. 
# 
# To parse .shtml files for server-side includes (SSI): 
# (You will also need to add "Includes" to the "Options" directive.) 
# 
AddType text/html .shtml 
AddOutputFilter INCLUDES .shtml 

(2)sudo nano /etc/apache2/extra/httpd-vhosts.conf

開始10
<VirtualHost *:80> 
    <Directory /Users/tidy/Sites/mysite.com> 
    Options +FollowSymlinks +SymLinksIfOwnerMatch +Includes 
    DirectoryIndex index.htm 
    AllowOverride All 
    AddType text/html .shtml 
    AddOutputFilter INCLUDES .shtml 
    </Directory> 
    DocumentRoot /Users/tidy/Sites/mysite.com 
    ServerName mysite.local 
    ErrorLog "/Users/tidy/Sites/mysite.com/log/error_log" 
    CustomLog "/Users/tidy/Sites/mysite.com/log/access_log" common 
</VirtualHost> 

(3)sudo nano /private/etc/apache2/users/tidy.conf

<Directory "/Users/tidy/Sites/"> 
    Options +Indexes +MultiViews +FollowSymlinks +SymLinksIfOwnerMatch +Includes 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    AddType text/html .shtml 
    AddOutputFilter INCLUDES .shtml 
</Directory> 

(4)sudo nano ~/Sites/mysite.com/.htaccess

AddType text/html .shtml 
AddHandler server-parsed .shtml 
DirectoryIndex index.html index.htm 
Options +Includes 
XBitHack on 

我還試圖通過執行chmod +x ~/Sites/mysite.com/partialHtml/businessResult.html然後包括文件以使用XBitHack on(顯然它使.html文件服務器側包括高效的,如果你不想使用.shtml文件)

顯然,我在做一個sudo apachectl configtest以確保一切正常。

我得到一個警告(我試圖擺脫),但語法是確定的。

httpd: Could not reliably determine the server's fully qualified domain name, using complexity.local for ServerName 
Syntax OK 

然後,sudo apachectl restart

這是我最近在cat ~/Sites/mysite.com/log/access_log

::1 - - [08/Jan/2013:12:11:05 +0000] "OPTIONS * HTTP/1.0" 200 - 
::1 - - [08/Jan/2013:12:11:07 +0000] "OPTIONS * HTTP/1.0" 200 - 
::1 - - [08/Jan/2013:12:11:08 +0000] "OPTIONS * HTTP/1.0" 200 - 
::1 - - [08/Jan/2013:12:11:15 +0000] "OPTIONS * HTTP/1.0" 200 - 
::1 - - [08/Jan/2013:12:11:16 +0000] "OPTIONS * HTTP/1.0" 200 - 
::1 - - [08/Jan/2013:12:11:17 +0000] "OPTIONS * HTTP/1.0" 200 - 
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET/HTTP/1.1" 200 3924 
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /css/site.css HTTP/1.1" 200 3077 
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /css/bootstrap.css HTTP/1.1" 200 124223 
127.0.0.1 - - [08/Jan/2013:12:12:03 +0000] "GET /img/logo.png HTTP/1.1" 200 19217 
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/searchFormGradient.gif HTTP/1.1" 200 501 
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/glyphicons-halflings-white.png HTTP/1.1" 200 8777 
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /img/headerGradient.png HTTP/1.1" 200 216 
127.0.0.1 - - [08/Jan/2013:12:12:04 +0000] "GET /js/bootstrap.min.js HTTP/1.1" 200 31596 
::1 - - [08/Jan/2013:12:12:14 +0000] "OPTIONS * HTTP/1.0" 200 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET/HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /css/bootstrap.css HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /js/bootstrap.min.js HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/logo.png HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /css/site.css HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/headerGradient.png HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/glyphicons-halflings-white.png HTTP/1.1" 304 - 
127.0.0.1 - - [08/Jan/2013:12:12:18 +0000] "GET /img/searchFormGradient.gif HTTP/1.1" 304 - 

活動的HTTP/1.1 304代碼爲HTTP Error 304 - Not modified這是不是一個錯誤,這是從服務器到瀏覽器的信號,自上次請求以來,當前內容並未發生變化。

你可以從GET要求看,有沒有/partialHtml/businessResult.shtml

這是我最近在cat ~/Sites/mysite.com/log/error_log

[Tue Jan 08 11:24:49 2013] [error] [client 127.0.0.1] File does not exist: /Users/tidy/Sites/mysite.com/favicon.ico 

而且畢竟這些活動跡象...服務器端包含機制不能正常工作:-(

任何協助,不勝感激

整齊。

回答

0

我想我有解決我的問題。

我與Windows 7上的服務器端包含的問題相同,因爲我的錯誤印象是只有所包含的文件必須具有.shtml擴展名。

由於行: <!--#include file="partialHtml/businessResult.shtml" -->

在一個文件稱爲: index.html

服務器側包括模塊沒有被預處理的文件。

當我將index.html更改爲index.shtml後,服務器端包含正確模塊 預處理的所有內容。

TL; DR - 包含服務器端的文件必須包含.shtml擴展名。