好幾年沒有編譯安裝Apahce,今天一試,發現還真不是一件容易事兒。幾經測試,發現我們在安裝前需要以下幾樣東西:
1)gcc
2)gcc-c++
3)APR
4)APR-Utils
5)PCRE
6)YUM
操作步驟如下:
第1步:
# yum -y groupinstall "Developement Tools"
//這個把gcc及後面安裝PCRE-8.38需要的編譯器全部都安裝上
第2步:下載Apache、APR、APR-Utils、PCRE
# wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.35.tar.gz
# wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.5.tar.gz
# wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
可以看到,下載的pcre的版本比較低。是因爲pcre2,無法通過。
第3步:安裝APR
# tar xvf apr-1.6.5.tar.gz
# cd apr-1.6.5
# ./configure
# make && make install
# cd ..
第4步:安裝APR-Utils,這一步裏,要先安裝expat-devel,否則會出錯。而且,163.com的yum源裏沒有這個軟件包,只能用阿里雲的yum源。更改yum源,請見我前面一篇文章。
# yum -y install expat-devel
# tar xvf apr-util-1.6.1.tar.gz
# cd apr-util-1.6.1
# ./configure --with-apr=/usr/local/apr
# cd ..
第5步:安裝PCRE
# tar xvf pcre-8.38.tar.gz
# cd pcre-8.38
# ./configure --prefix=/usr/local/pcre
# cd ..
第6步:安裝Apache
# tar xvf httpd-2.4.35.tar.gz
# cd httpd-2.4.35
# ./configure --enable-so --with-pcre=/usr/local/bin/pcre-config
# make
# make install
# /usr/local/apache2/bin/apachectl start
這個時候,如果順利的話,就會安裝成功,可以使用/usr/local/apache2/bin/apachectl start來啓動Apache。這個不能加入systemctl的服務中去,還要做一番工作。