下載apache httpd
# wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz
2. 解壓 apache httpd
# tar xzvf httpd-2.4.10.tar.gz
編譯apache httpd
[[email protected]]# ./configure
checkingfor chosen layout... Apache
checkingfor working mkdir -p... yes
checkingfor grep that handles long lines and -e... /bin/grep
checkingfor egrep... /bin/grep -E
checkingbuild system type... i686-pc-linux-gnu
checkinghost system type... i686-pc-linux-gnu
checkingtarget system type... i686-pc-linux-gnu
configure:
configure:Configuring Apache Portable Runtime library...
configure:
checkingfor APR... no
configure:error: APR not found. Please read thedocumentation.
說明需要先安裝apr, apr-util和prce後再編譯httpd
3. 安裝apr
# wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.1.tar.gz
# wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.3.tar.gz
#tar xzvf apr-1.5.1.tar.gz
#cd apr-1.5.1.tar.gz
# ./configure--prefix=/usr/local/apr
#make
#make install
安裝apr-util
#tar xzvf apr-util-1.5.3.tar.gz
#cd apr-util-1.5.3
# ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/apr-1-config
#make
#make install
4. 安裝c++編譯器
# yum -y install gcc
# yum -y install gcc-c++
5. 安裝prce
# tar xzvf pcre-8.35.tar.gz
#cd pcre-8.35
#./configure --prefix=/usr/local/pcre
#make & make install
6. 編譯httpd
# ./configure --prefix=/usr/local/apache2--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
#make & make install
7. 將80端口在防火牆上關閉或者關閉防火牆
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
#/etc/rc.d/init.d/iptables save
重啓計算機後,防火牆默認已經開放了80和22兩個端口。
臨時性的完全關閉防火牆,可以不重啓機器:
#/etc/init.d/iptables status ##查看防火牆狀態
#/etc/init.d/iptable stop ## 本次關閉防火牆
#/etc/init.d/iptable restart ## 重啓防火牆
或者永久性關閉防火牆:
#chkconfig --level 35 iptables off ## 注意中間的是兩個英式小短線;重啓
8. 啓動apache httpd
在httpd.conf配置文件中增加如下配置:
PidFile "httpd.pid"
運行命令啓動:/usr/local/apache2/bin/apachectl start
9. 在瀏覽器中輸入:http://192.168.146.128/ 顯示It works 頁面則表示apachehttp server安裝成功了!