Apache脚本备忘

#
# Installation script
#
# Prepare for compilation environment
yum install -y groupinstall "Development Tools"

# Create a build directory
mkdir -p /opt/install/httpd

# Prepare for compilation source
cd /opt/install/httpd
curl -o httpd-2.4.2.tar.gz http://apache.etoak.com//httpd/httpd-2.4.2.tar.gz
curl -o apr-1.4.6.tar.gz http://mirrors.axint.net/apache/apr/apr-1.4.6.tar.gz
curl -o apr-util-1.4.1.tar.gz http://mirrors.axint.net/apache/apr/apr-util-1.4.1.tar.gz
curl -o pcre-8.30.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
tar -zxvf httpd-2.4.2.tar.gz
tar -zxvf apr-1.4.6.tar.gz
tar -zxvf apr-util-1.4.1.tar.gz
tar -zxvf pcre-8.30.tar.gz

# Install build dependencies
yum install -y pcre-devel
mv apr-1.4.6 httpd-2.4.2/srclib/apr
mv apr-util-1.4.1 httpd-2.4.2/srclib/apr-util

# Create a User Group
groupadd httpd
useradd -r -g httpd httpd

# Compile and deploy
cd httpd-2.4.2
./configure \
--prefix=/opt/server/web/httpd \
--bindir=/opt/server/web/httpd/bin \
--sbindir=/opt/server/web/httpd/bin \
--enable-mods-shared=all \
--with-included-apr \
--with-mpm=prefork
make
make install

# Postinstallation setup
cd /opt/server/web/httpd
chown -R httpd .
chgrp -R httpd .
chown -R root .
chown -R httpd htdocs

# Configuration
cp conf/httpd.conf conf/httpd.conf.bak
sed -i -e "s/User daemon/User http/" -e "s/Group daemon/Group http/" conf/httpd.conf
sed -i -e "s/ServerAdmin [email protected]/ServerAdmin [email protected]/" conf/httpd.conf
sed -i -e "s/#ServerName www.example.com:80/ServerName localhost:80/" conf/httpd.conf
cp bin/apachectl /etc/init.d/httpd
sed -i '/#!\/bin\/sh/a\# chkconfig: - 85 15\n# description: web server\n# processname: httpd\n# pidfile: /opt/server/web/httpd/logs/httpd.pid\n# config: /opt/server/web/httpd/conf/httpd.conf' /etc/init.d/httpd
chmod a+x /etc/init.d/httpd
##chkconfig --add httpd
##chkconfig --level 345 httpd on

# Additional
/etc/init.d/httpd start
/etc/init.d/httpd stop

猜你喜欢

转载自fly2wind.iteye.com/blog/1545482