linux源码下载阿帕奇,Ubuntu 12.04下源码安装Apache
環境:Ubuntu 12.04
【簡單安裝】
一般第一次安裝Apache都較為順利。
1. 下載并解壓
root@ubuntu:/home/qy/share#tar zxvf httpd-2.2.22.tar.gz
root@ubuntu:/home/qy/share#cd httpd-2.2.22
在http-2.2.22里有文件README和INSTALL,用more命令可以閱讀。
2. 配置
root@ubuntu:/home/qy/share/httpd-2.2.22#./configure --prefix=/usr/local/apache
--prefix參數指定了將要安裝到的目錄。此時/usr/local下還沒有該目錄,make install后才會出現。
注意:Apache在安裝時不會檢查參數是否正確,錯誤的參數會直接被丟棄,不會報告給用戶。所以使用echo $?命令檢查是否有錯誤,當輸出結果為0時表示沒有錯誤。
3. 編譯
root@ubuntu:/home/qy/share/httpd-2.2.22#make
4. 安裝
root@ubuntu:/home/qy/share/httpd-2.2.22#make install
5. 啟動服務器
root@ubuntu:/home/qy/share/httpd-2.2.22#cd /usr/local/apache/bin
root@ubuntu:/usr/local/apache/bin#./apachectl start
為了以后使用方便,可以把啟動文件apachectl復制到/sbin下,以后直接apachectl start啟動。
#vi /etc/rc.local
增加一行 /sbin/apachectl start
6. 驗證Apache是否工作
此時,服務器端窗口應該顯示:
#ps -e|grep httpd
在客戶端瀏覽器輸入服務器的IP地址(或者http://localhost),IE應該顯示:It works!畫面。
Ubuntu重啟后,需要重啟Apache: apachectl start
停止服務器: ./apachectl stop
重啟服務器: ./apachectl graceful 或 ./apachectl restarted
通常,第一次安裝Apache沒有什么問題,但以后安裝,如果沒有apr,apr-util,pcre,在執行./configure的配置過程中可能遇到的錯誤:
make[2]: *** [install] Error 1
make[2]: Leaving directory `/tmp/httpd-2.2.22/srclib/apr-util'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/tmp/httpd-2.2.22/srclib'
make: *** [install-recursive] Error 1
Apache2.0.x與Apache2.2.x在apr上有本質的區別,前者為依賴公用apr,后者依賴于自身的apr。2.0.x的編譯基本上沒有apr方面的問題,除非,在編譯前,安裝了非2.0.x所需的apr,如果是這樣,則需要將已經安裝的apr去除,然后再編譯。HTTP Sever2.2.22修復了不少重要安全問題,包含APR(Apache Portable Runtime)1.4.5和APR-util(Apache Utility Library)1.4.2。因此不需要像網上其它教程那樣從外部找源碼安裝apr和apr-util。將安裝前已存在于系統中的apr去除后,再編譯apache2.2.x自身srclib里的apr和apr-util。其它操作系統這樣解決就沒問題了,但是Ubuntu不太一樣。安裝完apr和apr-util后,./configure配置Apache時可能會出現下面錯誤:
configure: error: Cannot use an external APR with the bundled APR-util
或
configure: error: APR version 1.2.0 or later is required
srclib目錄中有apr,apr-util,pcre三個源碼包,其中pcre是不可用的,編譯不出來,有如下錯誤:
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make: *** [pcrecpp.lo] Error 1
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/上下載的pcre-8.30也不可用。不妨用make check命令查看下錯誤出在什么地方。一般懷疑是g++版本低,更新即可。我沒有這樣做,而是直接用apt-get install libpcre3-dev安裝了pcre后,再安裝apache就沒問題了。
總結
以上是生活随笔為你收集整理的linux源码下载阿帕奇,Ubuntu 12.04下源码安装Apache的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python中赋值语句_python中赋
- 下一篇: case when 多条件_3年前的设计