先给出自动化编译安装httpd的脚本,后面的mysql,php-fpm,xcache等还在测试中

自动化编译安装httpd的脚本!
FUNDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Make sure  you are ready for installing apache!"
read -p "Please input the dir wher you want to download these packages!"  pkg
declare -a  numberlists
echo "Current dirpath is  $FUNCDIR"
( cd  $pkg  &&
 echo "apr-1.5.2.tar.bz2 is downloading please be patient!"
 wget http://mirrors.aliyun.com/apache/apr/apr-1.5.2.tar.bz2 &>/dev/null  && echo "apr-1.5.2.tar.bz2 has downloaded  successfully!"
 echo "apr-util-1.5.4.tar.bz2 is downloading please be patient!"
        tar xf  $pkg/`ls $pkg |grep "httpd"`   -C  /usr/local
        fi

        # "/usr/local/`ls /usr/local |grep apr-1`"
        #aprutildir= "/usr/local/`ls /usr/local |grep "apr-util"`"
        #httpddir= "/usr/local/`ls /usr/local |grep httpd `"
                (cd /usr/local/`ls /usr/local  | grep apr-[0-9].[0-9].[0-9]`
                if      [   -z   `ls /usr/local  | grep "apr$"`   ] ;then
                ./configure  --prefix=/usr/local/apr  | tee  /tmp/apr.out
                make
                make install
                else  echo "apr has installed early!"
                fi )

                (cd /usr/local/`ls /usr/local |grep "apr-util"`
                [  -z  "`ls /usr/local  | grep "apr-util$"`"  ]  &&
                (./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr |tee /tmp/apr-util.out &&  make && make install
                echo "Apr-util is installed sucessfully!") || echo "apr-util has installed early!")

                (cd /usr/local/`ls /usr/local | grep "httpd"`
                [  -z               `ls /usr/local | grep "apache" `    ]               && ( ./configure  --prefix=/usr/local/apache                                     --sysconfdir=/etc/httpd         --enable-so --enable-rewrite --enable-ssl --enable-cgi                                                                --enable-cgid --enable-modules=most --enable-mods-shared=most                                  --enable-mpms-shared=all                               --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util |tee  /tmp/httpd.out   &&  make && make install                          echo "Httpd is installed successfully!")   || echo "httpd has installed early" )
                ( cd     $FUNDIR                     &&  sed -n "p" httpd_conf_default |tee   /etc/httpd/httpd.conf >/dev/null               &&                             sed -n "p"  httpd_server_default |tee /etc/init.d/httpd24 >/dev/null && chkconfig --add httpd24  && chkconfig httpd24 on )
                (rm -rf /etc/httpd/conf.d/httpd.conf > /dev/null && echo "export PATH=$PATH:/usr/local/`ls /usr/local |                                               grep httpd`" > /etc/profile.d/apache.sh && chmod +x /etc/init.d/httpd24         && echo "/usr/local/apache/lib"                                        > /etc/ld.so.conf.d/apache.conf  && ldconfig  &&
                echo "Configuration is ok!"                         && [ -z "/usr/include/apache" ] && ln -s /usr/local/apache/include/                                /usr/include/apache     )
                (  echo "export PATH=$PATH:/usr/local/apache/bin" > /etc/profile.d/httpd.sh
                   echo  "It works!! "  )
        ;;       
        ${numberlists[1]})
        break
        esac
done

原创文章,作者:sjfbjs,如若转载,请注明出处:http://www.178linux.com/50533