第一步:下載Apache http server 源碼安裝包
[root@localhost ~]# cd /usr/local/src/ [root@localhost src]# wget https://dlcdn.apache.org//httpd/httpd-2.4.48.tar.gz
第二步:解壓縮安裝包,編譯安裝
[root@localhost src]# tar zxf httpd-2.4.48.tar.gz [root@localhost src]# cd httpd-2.4.48
進到httpd安裝目錄后,該怎么進行安裝呢?源碼包一般會帶有INSTALL、README之類的參考安裝文檔,我們在安裝之前可以看一下這些文檔。
[root@localhost httpd-2.4.48]# less INSTALL APACHE INSTALLATION OVERVIEW Quick Start - Unix ------------------ For complete installation documentation, see [ht]docs/manual/install.html or http://httpd.apache.org/docs/2.4/install.html $ ./configure --prefix=PREFIX $ make $ make install $ PREFIX/bin/apachectl start
可以看到指導說明:完整的安裝文檔可以看當前目錄下docs/manual/install.html這個文件或者是官方的在線文檔http://httpd.apache.org/docs/2.4/install.html
我們打開官方在線文檔看下安裝說明
可以看到我們需要GCC、apr、apr-util、pcre等支持,那么我先來安裝一下
[root@localhost httpd-2.4.48]# yum -y install gcc gcc-c++ make automake autoconf apr-devel apr-util-devel pcre-devel openssl openssl-devel [root@localhost httpd-2.4.48]# mkdir -p /apps/httpd [root@localhost httpd-2.4.48]# ./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl [root@localhost httpd-2.4.48]# make -j 2 [root@localhost httpd-2.4.48]# make install
至此,已經完成編譯安裝。
第三步,配置環境
[root@localhost httpd-2.4.48]# echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh [root@localhost httpd-2.4.48]# . /etc/profile.d/httpd.sh
第四步,啟動服務,並測試訪問
[root@localhost httpd-2.4.48]# apachectl start [root@localhost httpd-2.4.48]# ps -ef |grep http root 22814 1 0 11:43 ? 00:00:00 /apps/httpd/bin/httpd -k start daemon 22815 22814 0 11:43 ? 00:00:00 /apps/httpd/bin/httpd -k start daemon 22816 22814 0 11:43 ? 00:00:00 /apps/httpd/bin/httpd -k start daemon 22817 22814 0 11:43 ? 00:00:00 /apps/httpd/bin/httpd -k start root 22906 2790 0 11:43 pts/0 00:00:00 grep --color=auto http [root@localhost httpd-2.4.48]# netstat -an|grep -w 80 tcp6 0 0 :::80 :::* LISTEN [root@localhost httpd-2.4.48]#
訪問測試
至此,Apache http server已經正常提供web服務了。