PS:Apache http server 需要依賴 apr、apr-util、pcre,所以要先下載和安裝這三個東東。而apr-util和pcre又依賴apr,所以要先安裝apr。
步驟:
1、 下載apr、apr-util、pcre、Apache httpserver
地址如下:
apr/ apr-util: http://apr.apache.org/download.cgi
pcre: http://www.pcre.org/
apache http server: http://httpd.apache.org/download.cgi#apache24
2、 將檔案上傳到伺服器(linux)
例如目錄:/usr/mytest/source
3、 分別解壓四個檔案
例如解壓到目前的目錄:
解壓apr : tar –vxf apr-1.5.0.tar.gz(在source目錄下會多出一個目錄apr-1.5.0)
解壓apr : tar –vxf apr-util-1.5.3.tar.gz(在source目錄下會多出一個目錄apr-util-1.5.3)
解壓pcre : tar –vxf pcre-8.33.tar.gz(在source目錄下會多出一個目錄pcre-8.33)
解壓Apache http server:tar –vxf httpd-2.4.9.tar.gz(在source目錄下會多出一個目錄httpd-2.4.9)
PS:注意,我下載的都是tar.gz格式的,如果是其他格式的,請參考linux關於解壓方面的相關命令。
4、 安裝apr
切換到apr-1.5.0檔案夾下,依次執行命令:
(1)./configure--prefix=/usr/mytest /soft/apr (該命令的意思是配置安裝檔案,指定安裝路徑為絕對路徑)
(2)make (編譯)
(3)make install(安裝)
5、 安裝apr-util
切換到apr-util-1.5.3檔案夾下,依次執行命令:
(1)./configure--prefix=/usr/mytest /soft/apr-util --with-apr=/usr/mytest
/soft/apr/bin/apr-1-config
(該命令的意思是配置安裝檔案,指定安裝路徑為絕對路徑;且需要依賴apr,否則將會出錯)
(2)make (編譯)
(3)make install(安裝)
6、 安裝pcre
切換到pcre-8.33檔案夾下,依次執行命令:
(1)./configure--prefix=/usr/mytest /soft/pcre --with-apr=/usr/mytest
/soft/apr/bin/apr-1-config
(該命令的意思是配置安裝檔案,指定安裝路徑為絕對路徑;且需要依賴apr,否則將會出錯)
(2)make (編譯)
(3)make install(安裝)
7、 安裝Apache httpserver
切換到httpd-2.4.9檔案夾下,依次執行命令:
(1)./configure--prefix=/usr/mytest /soft/httpd
--with-apr=/usr/mytest/soft/apr/bin/apr-1-config --with-apr=/usr/mytest/soft/apr-util/bin/apu-1-config
--with-apr=/usr/mytest /soft/pcre/bin/pcre-config
(該命令的意思是配置安裝檔案,指定安裝路徑為絕對路徑;且需要依賴apr/apr-util/pcre,否則將會出錯)
(2)make (編譯)
(3)make install(安裝)
至此安裝完成並結束。
8、 啟動測試:
(1) 需要首先修改設定檔:(/usr/mytest /soft/httpd/bin/httpd.conf)
ServerName屬性
Listener屬性
PS:如果設定檔中Listen定義的是預設的80連接埠(或1024以下),那麼啟動Apache將需要root許可權以將它綁定在特權連接埠上。
參考網址:http://www.jinbuguo.com/apache/menu22/invoking.html
(2) 切換到/usr/mytest /soft/httpd/bin目錄下,
執行:./ apachectl –k start
(3) 到瀏覽器中輸入ServerName配置的屬性值,得到:It works!
9、 共用伺服器使用說明:
在httpd/htdocs 目錄下面增加目錄、檔案等,瀏覽器中即可查看。