#!/bin/bash
Apache_Soft_Dir=/soft
Apache_Version=2.2.29
Apache_Install_Dir=/application/apache$Apache_Version
Apache_LN_Dir=/application/apache
#Source function library
. /etc/init.d/functions
#install openssl
yum install -y openssl*
echo "---------step1:remove http---------s"
rpm -qa httpd*
for name in `rpm -qa httpd*`;do rpm -e --nodeps $name;done
echo "---------step2:add apache user---------"
groupadd apache
useradd -s /sbin/nologin -g apache -M apache
sleep 1
echo "---------step3:dowload apache soft---------"
mkdir -p /soft
cd /soft
wget http://mirrors.sohu.com/apache/httpd-2.2.29.tar.gz
echo "---------step4:install apache---------"
tar zxf httpd-2.2.29.tar.gz
cd httpd-2.2.29
./configure \
--prefix=$Apache_Install_Dir \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--with-mpm=worker \
--enable-so \
--enable-ssl \
--enable-rewrite
make&&make install
ln -s $Apache_Install_Dir $Apache_LN_Dir
cd $Apache_LN_Dir/conf
sed -i 's/^User daemon/User apache/g' httpd.conf
sed -i 's/^Group daemon/Group apache/g' httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName 127.0.0.1:80/g' httpd.conf
echo "---------step5:install cronolog---------"
cd /soft
wget http://down.teddylu.info/cronolog-1.6.2.tar.gz
tar zxf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make
make install
echo "---------step6:setup apache startup script---------"
cp ${Apache_LN_Dir}/bin/apachectl /etc/init.d/httpd
/etc/init.d/httpd start
action "Apache is installed !!!"/bin/true
开发apache一键安装部署脚本