Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Apache 2.2 安裝與配置 mod_layout 模組實戰指南

編輯:關於伺服器

什麼是 mod_layout?

mod_layout 可在 HTTP 回應的文件頭部、尾部或指定標籤前後動態插入內容。典型應用:

  • 全站統一加入免責聲明、版權宣告
  • 頁首插入橫幅廣告、導覽列
  • 支援 HTML、Text、CGI、Java、PHP、Perl 等多種內容類型

版本對應與下載

Apache 版本mod_layout 版本
1.33.1
2.04.1
2.25.1

下載位址:https://download.tangent.org/

Apache 2.2 編譯安裝步驟

# 1. 下載解壓
wget https://download.tangent.org/mod_layout-5.1.tar.gz
tar xvfz mod_layout-5.1.tar.gz
cd mod_layout-5.1

# 2. 編輯 Makefile,確認路徑
APXS=apxs
APACHECTL=apachectl
CC=`apxs -q CC`
INC=-I`apxs -q INCLUDEDIR` `$(APXS) -q CFLAGS`
LD_SHLIB=`apxs -q LDFLAGS_SHLIB`
# 關鍵:確保 APXS 與 APACHECTL 指向正確

# 3. 編譯安裝
make
make install

啟用配置範例

<VirtualHost *:80>
  <Directory /home/foo/public_html>
    AllowOverride None
    Options SymLinksIfOwnerMatch
    AddOutputFilter LAYOUT html
    LayoutFooter /menu.html
    LayoutIgnoreURI /diary/*
    LayoutIgnoreURI /linux/*
  </Directory>
</VirtualHost>

指令說明

  • AddOutputFilter LAYOUT html:啟用對 html 的處理,可追加 php、shtml 等
  • LayoutFooter /menu.html:在文件尾插入指定檔案內容
  • LayoutIgnoreURI:排除不需處理的 URI 路徑

重要限制:與 GZIP 衝突

若網頁已啟用 gzip 壓縮,mod_layout 將無法正常運作。 需在壓縮前插入內容,或針對特定類型關閉壓縮。生產環境建議配合 mod_deflate 的 SetOutputFilter 順序調整,或使用 mod_substitute 替代方案。

進階參考

完整指令文件:官方手冊

Copyright © Windows教程網 All Rights Reserved