Apache是一個基金會的名字,httpd纔是咱們須要安裝的軟件包apache
apr和apr-util是一個通用的函數庫,它讓httpd能夠不關聯底層操做系統平臺,能夠很方便的移植,若是不安裝這兩個,httpd就沒法工做。bash
步驟ide
一、下載httpd、apr和apr-util函數
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
二、解壓 httpd、apr和apr-utilspa
tar zxvf httpd-2.4.29.tar.gz tar zxvf apr-1.6.3.tar.gz tar jxvf apr-util-1.6.1.tar.bz2
三、安裝apr操作系統
cd /usr/local/src/apr-1.6.3 ./configure -prefix=/usr/local/apr make && make install
四、安裝apr-utilxml
cd /usr/local/src/apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
(安裝apr-util依賴apr)get
安裝過程可能會出現以下錯誤it
libtool:link:cannot find the library `/usr/local/src/apr-util-1.6.1/xml/expat/libexpat.la` or unhandled argument `/usr/local/src/apr-util-1.6.1/xml/expat/libexpat.la` make:*** [libaprutil-1.la] 錯誤 1
解決辦法是:編譯
yum install -y expat-devel
五、安裝httpd
cd /usr/local/src/httpd-2.4.29 ./configure \ //這裏的反斜槓是轉義字符,加上他能夠把一行命令寫成多行 --prefix=/usr/local/apache2.4 \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --enable-so \ --enable-mods-shared=most
這裏--prefix指定安裝目錄,
--enable-so表示啓用DSO,DSO的意思是把某些功能以模塊形式展現出來。
--enbale-mods-shared=most表示以共享的方式安裝大多數功能模塊,安裝後會在modules目錄下面看到這些文件。
爲了不make出現錯誤,提早安裝一些庫文件
yum install -y pcre pcre-devel
編譯
make make install
安裝完成後,能夠查看modules下面的模塊文件
ls /usr/local/apache2.4/modules
這些模塊並不會所有加載,若是想使用哪些模塊,在配置文件裏配置便可。
查看加載了哪些模塊:
/usr/local/apache2.4/apachectl -M
或者
/usr/local/apache2.4/httpd -M