1.安裝依賴(lài)包
(1)yum -y install pcre pcre-devel
如出現(xiàn)錯(cuò)誤util_pcre.c:128: error: PCRE_DUPNAMES undeclared (first use in this function)
那么是版本較低下載源碼進(jìn)行安裝(http://www.tjdsmy.cn/)
配置路徑可以為:./configure --prefix=/usr/local/pcre
(2)安裝apr
或者下載源碼包安裝,下載地址:http://www.tjdsmy.cn/apr/
./configure --prefix=/usr/local/apr
make && make install
cd ../apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make insatll
2.下載httpd源碼進(jìn)行安裝
(1)http://www.tjdsmy.cn//httpd/httpd-2.4.18.tar.gz
(2)解壓
tar -zxvf httpd-2.4.18.tar.gz
cd ttpd-2.4.18
(3)配置
./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre=/usr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=all --enable-mpms-shared=all --with-mpm=event
說(shuō)明:
--prefix=/usr/local/httpd24 :安裝位置;
--sysconfdir=/etc/httpd24 :配置文件位置;
--enable-so :支持DSO動(dòng)態(tài)裝載模塊;
--enable-ssl :支持SSL/TLS,可實(shí)現(xiàn)https協(xié)議訪(fǎng)問(wèn),需要安裝openssl-devel;
--enable-cgi :支持CGI腳本;
--enable-rewrite :支持URL重寫(xiě);
--with-zlib :使用指定的zlib壓縮庫(kù),不指定路徑會(huì)自動(dòng)尋找;
--with-pcre :使用指定的pcre庫(kù),增強(qiáng)的正則表達(dá)式分析工具;不指定路徑會(huì)自動(dòng)尋找 需已安裝pcre-devel;
--with-apr=/usr/local/apr :指定依賴(lài)apr程序安裝位置;
--with-apr-util=/usr/local/apr-util :指定依賴(lài)apr-util程序安裝位置;
--enable-modules=all :支持動(dòng)態(tài)啟用模塊;all:所有,most:常用;
--enable-mpms-shared=all :編譯并共享模塊;
--with-mpm=event :默認(rèn)啟用模塊;{prefork|worker|event}
3.啟動(dòng)環(huán)境配置
(1)添加變量
vi /etc/proflie
在最后面添加
export PATH=/usr/local/httpd24/bin:$PATH
(2)啟動(dòng)
apachectl start