服务器端包含

时间:2011-09-18 14:21:32

标签: html apache2 server-side-includes

我在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.html homepage.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 是否需要进行不同的配置?

1 个答案:

答案 0 :(得分:0)

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

我的/ etc / apache2 / sites-available / default文件:

<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

这使它对我有用,希望你能让它运转起来。

- 托马斯