【问题标题】:Server Side Includes服务器端包括
【发布时间】:2011-11-19 16:42:09
【问题描述】:

我在 Apache 日志中收到以下错误消息:

unable to include potential exec "header.html" in parsed file /Users/sikusiku/Sites/ss-git/homepage.shtml

我基本上试图从 homepage.shtml 中包含 header.html。我在 homepage.html 中使用了非常基本的指令(header.htmlhomepage.shtml 都位于文档根目录中):

<!--#include virtual="header.html" -->

我认为我在 httpd.conf 中正确打开了 SSI:

Options Indexes FollowSymLinks ExecCGI Includes
...
AddType text/html .shtml
...
# XBitHack doesn't have anything to do with this, but I added it anyway.
XBitHack on

我错过了什么吗?包含的文件,即 header.html 是否需要进行不同的配置?

【问题讨论】:

  • 将文件命名为 shtml 后就不需要 XBitHack。如果 header.html 与 shtml 位于同一目录中,只需执行
  • 试试 virtual="/header.html"。否则;该错误似乎意味着一些权限错误。尝试 chmod header.html 使其不可执行。
  • 很遗憾,这两个建议没有奏效。
  • 在我的站点上还有一点不同:我在 apache 配置中有“选项 + 包含”。日志文件中的错误信息是否改变了?
  • 试过 Options +Includes, Options Includes -IncludesNOEXEC... 都没有用。

标签: html apache2 server-side-includes


【解决方案1】:

我刚刚在 ubuntu 服务器 11.10 上用 apache2 自己解决了这个问题。

我的 /etc/apache2/sites-available/默认文件:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

我在 /var/www 目录指令中将 AllowOverride None 更改为 All。

我在 /var/www/.htaccess 中的 .htaccess 文件:

Options +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

最后我确定 include.load 位于启用 mods 的文件夹中,这是为了加载 mod_includes.so 模块。

sudo ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/include.load

这会在 mods-available 中创建一个指向 include.load 的符号链接。

终于重启apache了

sudo service apache2 restart

这使它对我有用,希望你也能正常工作。

-- 托马斯

【讨论】:

猜你喜欢
  • 2011-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-15
  • 2011-06-03
相关资源
最近更新 更多