Apache>设置服务器端包含> OSX Snow Leopard>还是行不通

时间:2013-01-08 12:37:07

标签: apache osx-snow-leopard server-side-includes

我已经研究了大约2个多小时,包括准备这份报告的时间超过1小时(考虑到我24小时内没有睡觉,我必须是一个慢工人:-P)

虚拟服务器端包含在Dreamweaver中工作(图像呈现除外),但在浏览网页时不起作用。

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

我意识到我已经覆盖了太多的配置设置(如果有一种更简单,更优雅的方式,也许只是在.htaccess中使用~/Sites/mysite.com/文件,那么请注释); - )< / p>

从顶部开始(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

<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

我还尝试使用XBitHack on chmod +x ~/Sites/mysite.com/partialHtml/businessResult.html然后包含该文件(显然它会使.html文件服务器端包含效率,如果您不想使用{{ 1}}}文件)

显然我正在做.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

毕竟......服务器端包含机制不起作用: - (

非常感谢任何帮助。

整洁。

1 个答案:

答案 0 :(得分:0)

我想我有解决问题的方法。

我在Windows 7上遇到了与服务器端包含相同的问题,因为我误以为所包含的文件必须具有.shtml扩展名。

因为这行: <!--#include file="partialHtml/businessResult.shtml" -->

在一个名为的文件中: index.html

服务器端包含模块未预处理文件。

我将index.html更改为index.shtml后,服务器端正确包含模块 预处理一切。

TL; DR - 包含服务器端包含的文件必须具有.shtml扩展名。