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

Fedora Linux 編譯安裝 Apache httpd 解決 apr/apr-util 缺失報錯實戰

編輯:Linux 教學

錯誤現象

libtool: link: `passwd/apr_getpass.lo' is not a valid libtool object
make[3]: *** [libapr-1.la] Error 1

環境:Fedora 8、Apache httpd 2.2.8 源碼編譯。
根因:httpd 源碼包**不再捆綁 apr/apr-util**,需獨立安裝並指定路徑。

解決流程:獨立編譯安裝 apr & apr-util 並關聯 httpd

1. 下載並安裝 APR (Apache Portable Runtime)

wget https://dlcdn.apache.org/apr/apr-1.7.4.tar.gz
tar -zxvf apr-1.7.4.tar.gz
cd apr-1.7.4
./configure --prefix=/usr/local/apr-httpd
make && sudo make install

2. 下載並安裝 APR-util (依賴 APR)

wget https://dlcdn.apache.org/apr/apr-util-1.6.3.tar.gz
tar -zxvf apr-util-1.6.3.tar.gz
cd apr-util-1.6.3
./configure --prefix=/usr/local/apr-util-httpd --with-apr=/usr/local/apr-httpd
make && sudo make install

3. 重新配置 httpd 指定 apr/apr-util 路徑

cd /path/to/httpd-2.2.8
make clean          # 清理上次失敗的構建產物
./configure --prefix=/usr/local/httpd \
            --with-apr=/usr/local/apr-httpd \
            --with-apr-util=/usr/local/apr-util-httpd
make && sudo make install

關鍵點總結

  • 依賴順序:APR → APR-util → httpd。
  • --with-apr / --with-apr-util:指向各自的 --prefix 安裝路徑,而非源碼目錄。
  • make clean:編譯失敗後**必須清理**,否則殘留的無效 libtool 對象 (如報錯中的 apr_getpass.lo) 會導致後續構建持續失敗。
  • 現代發布版:Fedora/RHEL/CentOS 直接 dnf install httpd apr-devel apr-util-devel 即可獲得穩定、安全更新的版本,**源碼編譯僅用於特定版本需求/特殊編譯選項/學習目的**。

驗證安裝

/usr/local/httpd/bin/apachectl -V
# 輸出包含:
# Server version: Apache/2.2.8
# Server built:   ...
# Server's Module Magic Number: ...
# Server loaded:  APR 1.7.4, APR-Util 1.6.3
# Compiled using: APR 1.7.4, APR-Util 1.6.3

結語

Apache httpd 編譯報錯 not a valid libtool object 90% 因 **apr/apr-util 缺失或路徑錯誤**。獨立安裝並正確指定 --with-apr/--with-apr-util、執行 make clean 重構,即可順利編譯。生產環境請優先使用發布版包管理器。

Copyright © Windows教程網 All Rights Reserved