#!/bin/bash
#witten by sys520084          2008 4 9 2
##########################################################################################
# NOTE:
# The readme text is written by chinese.
# Please see this scripts in your chinese System.
##########################################################################################
#本脚本将帮助你自动安装apache服务器,如果你对本脚本有什么改进意见的话请通过下列方式和我联系
#email:sys520084@gmail.com
#qq:402793645
#msn:sys520084@hotmail.com
function HTTPINSTALL() {
read -p "请输入下载目录: " LOCALADDRESS
cd $LOCALADDRESS
read -p "Please keyin your download web address: " DOWNLOAD_ADDRESS
wget $DOWNLOAD_ADDRESS
SOURCEADDRESS=/usr/local/src
cd $SOURCEADDRESS
tar -zvxf $LOCALADDRESS/httpd*
#安装apache
cd $SOURCEADDRESS/httpd*
./configure \
--prefix=/usr/local/apache2 \
--enable-modules=all \
--enable-mods-shared=all \
--enable-cache \
--enable-file-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-dbd \
--enable-logio \
--enable-mime-magic \
--enable-proxy \
--enable-proxy-connect \
--enable-proxy-ftp \
--enable-proxy-http \
--enable-proxy-ajp \
--enable-proxy-balancer \
--enable-ssl \
--enable-http \
--enable-dav \
--enable-cgi \
--enable-cgid \
--enable-dav-fs \
--enable-dav-lock \
--enable-rewrite \
--with-ssl=/usr/include/openssl/ \
--enable-so \
--with-mpm=worker
make clean
make
make install
ln -s /usr/local/apache*/bin/apachectl /etc/rc.d/init.d/httpd
}


netstat -tuln | grep ":80 "
if [ "$?" == "0" ]; then
rpm -qa | grep httpd
    if [ "$?" == "0" ]; then
        service httpd stop
        rpm -e httpd
        HTTPINSTALL
    else
           /usr/local/apache*/bin/apachectl stop
       rm -rf /usr/local/apache*
       HTTPINSTALL
    fi         
else    
   HTTPINSTALL
fi