【问题标题】:How to get server side includes to work on Apache which is installed on Centros 7?如何让服务器端包括在 Centos 7 上安装的 Apache 上工作?
【发布时间】:2019-09-27 22:47:58
【问题描述】:

我有 ssi 在 InMotionHosting 上工作,但无法让它在本地 Centros 7 安装上工作。 Apache 2.4.6 版

httpd -M 显示 so_module 已加载,但 mod_include 未加载。

当我尝试添加 mod_include 时出现错误: httpd: Syntax error on line 55 of /etc/httpd/conf/httpd.conf: Can't locate API module structuremod_include' 在文件 /etc/httpd/modules/mod_include.so 中:/etc/httpd/modules/mod_include.so:未定义符号:mod_include'

我尝试修改httpd.conf文件:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    Options +Includes
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

SSI 仍然失败。

索引文件很简单:

<h1>Test page</h1>
/var/www/index.html
<br/>
<!--#echo var="DATE_LOCAL" -->
<!--#include virtual="./insert.shtml" -->

我错过了什么?

【问题讨论】:

    标签: apache centos7 ssi


    【解决方案1】:

    通过设置 XBitHack 让 ssi 在 Centros 8 上工作。

    httpd.conf:

    <Directory "/var/www/html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Options +Includes
        # AddType text/html .shtml
        # AddHandler server-parsed .shtml
        XBitHack on
         Require all granted
    </Directory>
    

    在 /var/www/html 中做:

    chmod +x test.shml
    

    index.htm:

    现在可以使用 .shtml 文件了。

    服务器版本:Apache/2.4.37 (centos)

    【讨论】:

      【解决方案2】:

      经过几次失败后,我发现这是可行的:

      AddType text/html .shtml

      AddHandler 服务器解析的 .html

      我发现的所有示例都显示了 AddHandler 服务器解析的 .shtml。我的主文件是 index.html,ssi 文件是 test.shtml。

      希望这对某人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-05-27
        • 2022-07-02
        • 1970-01-01
        • 1970-01-01
        • 2016-08-26
        • 2018-08-13
        • 2020-11-11
        • 1970-01-01
        相关资源
        最近更新 更多