- #!/bin/bash
- #=========================================
- #File:
- #Description:
- #Author: smileliuyb
- #Modify: smileliuyb
- #Creation Date:
- #Last Modified:
- #=========================================
- lamppath=/usr/local/src/lamp
- ####Apache packet version
- apr="apr-1.4.6"
- aprutil="apr-util-1.5.1"
- httpd="httpd-2.4.3"
- ####MySql packet version
- ####PHP packet version
- check_error() {
- if [ $1 -ne 0 ];then
- echo `date`":Can't $2" >> /tmp/lampinstall_log
- echo "Can't $2"
- exit 10
- fi
- }
- install() {
- installApache
- }
- installApache() {
- rpm -qa gcc | grep gcc &> /dev/null
- if [ $? -ne 0 ];then
- echo `date`':Install gcc' >> /tmp/lampinstall_log
- yum install -y gcc &> /dev/null
- check_error $? "find and install gcc!"
- echo `date`":Gcc install successful!" >> /tmp/lampinstall_log
- echo "Gcc install successful!"
- fi
- rpm -qa pcre-devel | grep pcre-devel &> /dev/null
- if [ $? -ne 0 ];then
- echo `date`':Install prce-devel' >> /tmp/lampinstall_log
- yum install -y pcre-devel &> /dev/null
- check_error $? "find and install prce-devel!"
- echo `date`':Prce-devel install successful!' >> /tmp/lampinstall_log
- echo "Prce-devel install successful"
- fi
- rpm -qa zlib-devel | grep zlib-devel &> /dev/null
- if [ $? -ne 0 ];then
- echo `date`":Install zlib-devel" >> /tmp/lampinstall_log
- yum install -y zlib-devel &> /dev/null
- check_error $? "find and install zlib-devel!"
- echo `date`":Zlib-devel instll successful!" >> /tmp/lampinstall_log
- echo "Zlib-devel install successful!"
- fi
- mkdir -p $lamppath >> /tmp/lampinstall_log 2>&1
- check_error $? "mkdir $lamppath!"
- cd $lamppath
- #wget http://apache.dataguru.cn/apr/$apr.tar.bz2
- #check_error $? "wget apr!"
- cp /tmp/$apr.tar.bz2 ./
- check_error $? "find $apr.tar.bz2.bz2 from /tmp!"
- echo `date`":Copy $apr.tar.bz2 successful!" >> /tmp/lampinstall_log
- tar fxj $apr.tar.bz2 >> /tmp/lampinstall_log 2>&1
- check_error $? "tar fxj $apr.tar.bz2!"
- echo `date`":Tar fxj $apr.tar.bz2 successful!" >> /tmp/lampinstall_log
- cd $lamppath/$apr
- echo `date`":Start ./configure && make && make install!" >> /tmp/lampinstall_log
- ./configure --prefix=/usr/local/apr >> /tmp/lampinstall_log 2>&1
- check_error $? "./configure apr!"
- make >> /tmp/lampinstall_log 2>&1
- check_error $? "make apr!"
- make install >> /tmp/lampinstall_log 2>&1
- check_error $? "make install apr!"
- echo `date`":Install apr successful!" >> /tmp/lampinstall_log
- echo "Install apr successful!"
- #
- cd $lamppath
- #wget http://labs.mop.com/apache-mirror/apr/$aprutil.tar.bz2
- #check_error $? "wget apr-util!"
- cp /tmp/$aprutil.tar.bz2 ./
- check_error $? "find $aprutil.tar.bz2 from /tmp!"
- echo `date`":Copy $aprutil.tar.bz2 successful!" >> /tmp/lampinstall_log
- tar fxj $aprutil.tar.bz2 >> /tmp/lampinstall_log 2>&1
- check_error $? "tar fxj $aprutil.tar.bz2!"
- echo `date`":Tar fxj $aprutil.tar.bz2 successful!" >> /tmp/lampinstall_log
- cd $lamppath/$aprutil >> /tmp/lampinstall_log
- echo `date`":Start ./configure && make && make install!" >> /tmp/lampinstall_log
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ >> /tmp/lampinstall_log 2>&1
- check_error $? "./configure apr-util"
- make >> /tmp/lampinstall_log 2>&1
- check_error $? "make apr-util"
- make install >> /tmp/lampinstall_log 2>&1
- check_error $? "make install apr-util"
- echo `date`":Install apr-util successful!" >> /tmp/lampinstall_log
- echo "Install apr-util successful!"
- #
- cd $lamppath
- #wget http://apache.etoak.com/httpd/$httpd.tar.gz
- #check_error $? "wget httpd.tar.gz"
- cp /tmp/$httpd.tar.gz ./
- check_error $? "find $httpd.tar.gz from /tmp!"
- echo `date`":Copy $httpd.tar.gz successful!" >> /tmp/lampinstall_log
- tar fxz $httpd.tar.gz >> /tmp/lampinstall_log 2>&1
- check_error $? "tar fxz $httpd.tar.gz!"
- echo `date`":Tar fxz $httpd.tar.gz successful!" >> /tmp/lampinstall_log
- cd $lamppath/$httpd >> /tmp/lampinstall_log
- echo `date`":Start ./configure && make && make install!" >> /tmp/lampinstall_log
- ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-module=so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --with-mpm=prefork --enable-nonportable-atomics --disable-ipv6 --with-sendfile >> /tmp/lampinstall_log 2>&1
- # ./configure --prefix=/usr/local/apache2 --with-arp=/usr/local/apr/ --with-arp-util=/usr/local/apr-util/ enable-module=so --enable-deflate=shared --enalbe-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --with-mpm=prefork<进程~线程模式--with-mpm=worker> --enable-nonportable-atomics<prefork 原子互斥模式,优化CPU> --disable-ipv6 --with-sendfile
- check_error $? "./configure httpd!"
- make >> /tmp/lampinstall_log 2>&1
- check_error $? "make httpd!"
- make install >> /tmp/lampinstall_log 2>&1
- check_error $? "make install httpd!"
- echo `date`":Install httpd successful!" >> /tmp/lampinstall_log
- echo "Install httpd successful!"
- echo "Install LAMP successful!"
- echo `date`":Install LAMP successful!" >> /tmp/lampinstall_log
- }
- start() {
- /usr/local/apache2/bin/apachectl -k start
- }
- case $1 in
- install) install;;
- start) start;;
- *) echo $"Usage like ./lamp.sh install|start";;
- esac