Requirements: source code compiled Apache
Environment: CentOS 6 Desktop version of 64-bit system installation
Software: httpd-2.4.12.tar.gz, pcre-8.31.tar.bz2, apr-util-1.5.3, apr-1.5.1.tar.gz
Note: Currently only in the CentOS 6 environment testing, if there are errors may be dependent on the installation of the package is missing, originally wanted to put these several source packages uploaded, upload has failed, the above several source packages need to download on the Internet
[email protected] ~]# cat apache.sh
#!/bin/bash
#
#适用版本CentOS 6 64-bit
#2017.5.11
. /etc/init.d/functions
Dir=/root/test
Del_dir () {
Read-p "need to delete ${dir} delete [y|y/n|n]:" Del
Case $del in
Y|y)
RM-RF $dir
mkdir $dir
CD $dir
;;
N|n)
echo "Installation Termination"
Exit 7
;;
*)
echo "Please enter the correct value"
Exit 8
;;
Esac
}
[!-D $dir] && {
mkdir $dir
CD $dir
} || Del_dir
Yum-y install gcc gcc-c++ cmake ncurses-devel Bison ncurses
Sleep 2
echo "################################# #下载依赖包 ###################################"
wget http://172.2.0.68/apr-1.5.1.tar.gz
wget http://172.2.0.68/apr-util-1.5.3.tar.gz
wget http://172.2.0.68/pcre-8.31.tar.bz2
wget http://172.2.0.68/httpd-2.4.12.tar.gz
#wget Http://172.2.0.68/configure.txt
[$?-eq 0] && echo "Download apr dependency package, ready to install" | | Exit 7
Sleep 5
TAR-XZVF apr-1.5.1.tar.gz
TAR-XZVF apr-util-1.5.3.tar.gz
Sleep 3
CD apr-1.5.1
[$?-eq 0] && {
./configure--PREFIX=/USR/LOCAL/APR
} || {
echo "Decompression packet Error"
Exit 9
}
echo "################### #准备编译 ##################"
Sleep 3
Make && make install
Cd..
[$?-EQ 0] && CD apr-util-1.5.3 | | Exit 5
./configure--prefix=/usr/local/apr-util/--WITH-APR=/USR/LOCAL/APR
echo "################### #准备编译 ##################"
Make && make install
Cd..
echo "########## #安装pcre ######################"
Sleep 4
TAR-JXVF pcre-8.31.tar.bz2
[$?-EQ 0] && CD pcre-8.31 | | Exit 6
./configure--prefix=/usr/local/pcre
Make && make install
echo "########## #安装apache ###############"
Cd..
Groupadd www
Useradd-m-G www-s/sbin/nologin www
TAR-XZVF httpd-2.4.12.tar.gz
[$?-EQ 0] && CD httpd-2.4.12 | | Exit 3
echo "################# #编译apache ##################"
#configure
./configure--prefix=/usr/local/apache--enable-so--enable-deflate--enable-expires--enable-headers-- Enable-modules=most--with-mpm=worker--enable-ssl--enable-rewite--with-apr=/usr/local/apr--with-apr-util=/usr/ Local/apr-util--with-pcre=/usr/local/pcre
[$?-eq 0] && echo "compile Apache Success" | | {
echo "Compiling Apache failed"
Exit 5
}
echo "################## #安装Apache ##############################"
Sleep 2
Make && make install
[$?-eq 0] && echo "################# #apache安装成功 #######" | | {
echo "Apache installation Failed"
Exit 7
}
Sleep 2
# #apache服务启动脚本
CP BUILD/RPM/HTTPD.INIT/ETC/INIT.D/HTTPD
chmod 700/etc/init.d/httpd
Sed-i ' s/httpd-\/usr\/sbin\/httpd/httpd-\/usr\/local\/apache\/bin\/httpd/g '/etc/init.d/httpd
Sed-i ' s/pidfile-\/var\/run/pidfile-\/usr\/local\/apache\/logs/g '/etc/init.d/httpd
Sed-i ' s/conffile=\/etc\/httpd\/conf\/httpd.conf/conffile=\/usr\/local\/apache\/conf\/httpd.conf/g '/etc/init.d/ httpd
[$?-eq 0] && echo "######## #继续 ############" | | Exit 5
Chkconfig--add httpd
[$?-eq 0] && echo "########## #添加httpd启动项成功 ########" | | echo "################## #添加httpd启动项失败 ############"
Chkconfig--level httpd on
This article is from "think one or two" blog, please be sure to keep this source http://250919938.blog.51cto.com/962010/1924392
CentOS 6 Apache source code compile one-click deployment script