萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 伺服器教學

Apache 編譯常見錯誤:APR / APR-Util / PCRE Not Found 解決方案全紀錄

錯誤現象

checking for APR... no
configure: error: APR not found. Please read the documentation.

解決步驟

  1. 安裝 APR
    下載:apr.apache.org
    cd /tmp/52lamp
    tar -zxvf apr-1.4.2.tar.gz
    cd apr-1.4.2
    ./configure && make && make install
  2. 安裝 APR-Util
    下載:chinaunix.net
    tar -zxvf apr-util-1.3.9.tar.gz
    cd apr-util-1.3.9
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    make && make install
  3. 仍報 APR-util not found?指定路徑重新配置 Apache
    ./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

    若出現 pcre-config for libpcre not found,續下一步。

  4. 安裝 PCRE
    下載:sourceforge.net
    unzip -o pcre-8.10.zip
    cd pcre-8.10
    ./configure --prefix=/usr/local/pcre
    make && make install
  5. 最終配置 Apache
    ./configure --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
    # 其他參數如 --prefix 等自行添加
    echo $?  # 輸出 0 表示配置成功
    make && make install

服務註冊與防火牆

  1. 複製啟動腳本:cp /usr/local/httpd/bin/apachectl /sbin/
  2. 啟動:apachectl start
  3. 開機自啟:編輯 /etc/rc.d/rc.local 加入 /sbin/apachectl start
  4. 加入服務管理:
    cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
    編輯第二行加入:
    #chkconfig: 345 85 15
    #description: httpd for 52lamp 20101016 21:54
    chmod a+x /etc/rc.d/init.d/httpd
    chkconfig --add httpd
    ntsysv 即可看到服務。
  5. 驗證進程:ps -e | grep httpd
  6. 局域網無法存取?關閉防火牆或開放 80 埠:
    vi /etc/sysconfig/iptables 新增 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    service iptables restart

提示

Apache 配置不檢查參數正確性,錯誤參數會被靜默忽略。用 echo $? 檢查返回碼(0 為成功)。

copyright © 萬盛學電腦網 all rights reserved