要自行編譯原始檔,必須確認機器上有安裝 gcc 或是其它 ANSI-C 編譯器,以及 apr/apr-util
下載 Apache2 目前版本 2.2.11
# wget http://ftp.mirror.tw/pub/apache/httpd/httpd-2.2.11.tar.gz解壓縮
# tar -zxf httpd-2.2.11.tar.gz配置編譯參數
#cd httpd-2.2.11 #./configure \ --prefix=/usr/local/apache2 \ --enable-so \ --enable-ssl \ --enable-rewrite \ --enable-deflate \ --enable-cache \ --enable-mem-cache \ --enable-file-cache \ --enable-disk-cache \ --enable-mods-shared=most其中,/usr/local/apache2 是 Apache2 標準的安裝路徑,這是可自行選擇的,在 config.layout 中有許多安裝範本可供參考。
安裝 Apache2
#make #make install啟動及關閉 Apache2
/usr/local/apache2/bin/apachectl -k start /usr/local/apache2/bin/apachectl -k stop啟動後,開啟瀏覽器 http://ip ,測試 Apache2 是否正常運作
開機自動啟動
由於 tarball 方式安裝的 Apache2 ,不會在 setup 內的 System Service 出現,所以必需自行處理自動啟動的部份。
#cd /etc/init.d #vi apache2將以下代碼貼上
#!/bin/sh # description: Apache auto start-stop script. # chkconfig: - 85 15 APACHE_HOME=/usr/local/apache2 APACHE_OWNER=root if [ ! -f "$APACHE_HOME/bin/apachectl" ] then echo "Apache startup: cannot start" exit fi case "$1" in 'start') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl -k start" ;; 'stop') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl -k stop" ;; 'restart') su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl restart" ;; esac存檔後離開,執行下列命令:
#chmod +x apache2 #chkconfig --add apache2 #chkconfig --level 345 apache2 on測試上面的動作有沒有問題
#service apache2 start #service apache2 stop重新開機,檢查 Apache2 是否有自動啟動,若一切正常,那就大功告成囉
錯誤訊息
如果沒有 gcc 及 apr / apr-util,在編譯階段會出現以下錯誤
checking for chosen layout... Apache checking for working mkdir -p... yes checking build system type... i686-pc-linux-gnuoldld checking host system type... i686-pc-linux-gnuoldld checking target system type... i686-pc-linux-gnuoldld Configuring Apache Portable Runtime library ... checking for APR... reconfig configuring package in srclib/apr now checking build system type... i686-pc-linux-gnuoldld checking host system type... i686-pc-linux-gnuoldld checking target system type... i686-pc-linux-gnuoldld Configuring APR library Platform: i686-pc-linux-gnuoldld checking for working mkdir -p... yes APR Version: 1.3.3 checking for chosen layout... apr checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/root/httpd-2.2.11/srclib/apr': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details. configure failed for srclib/apr
沒有留言:
張貼留言