shell脚本一键安装二进制Apache

转载来源 :shell脚本一键安装二进制Apache : http://www.178linux.com/23401

安装背景:用的一台最小化安装的centos6。

编译安装安装的必备安装gcc,gcc-c++

安装包arp,arp-util以及pcre的压缩包已经传到七牛,没有通过官网下载。太慢。

apache是通过官网下载的,所以下载比较慢,需要的话更改下地址

不足,只按照正常流程写,未做任何异常判断处理

#/bin/bash

#一键安装Apache
#安装GCC
echo "安装GCC"
yum install -y gcc gcc-c++
#下载安装包
wget http://7xogt1.com1.z0.glb.clouddn.com/httpd.tar.gz -O /usr/local/src/httpd.tar.gz
cd /usr/local/src
#解压压缩包
tar -zxf httpd.tar.gz&>/dev/null&&echo "解压成功"||echo "解压失败"
tar -zxf apr-1.5.2.tar.gz
tar -zxf apr-util-1.5.4.tar.gz
tar -zxf pcre-8.39.tar.gz
#移动文件夹并改名
mv apr-1.5.2 ../apr
mv apr-util-1.5.4 ../apr-util
mv pcre-8.39 ../pcre
#安装apr
cd /usr/local/apr
./configure --prefix=/usr/local/apr&&make&&make install
#安装apr-util
cd /usr/local
cd apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config&&make&&make install
#安装pcre
cd /usr/local/pcre
./configure --prefix=/usr/local/pcre&&make&&make install
#官网下载Apache,并解压安装
wget http://apache.fayea.com//httpd/httpd-2.4.23.tar.gz -O /usr/local/src/httpd-2.4.23.tar.gz
cd /usr/local/src
tar -zxf httpd-2.4.23.tar.gz
mv httpd-2.4.23 ../Apache2
cd /usr/local/Apache2
./configure --prefix=/usr/local/Apache2/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/&&make&&make install
#关闭iptables
service iptables stop
chkconfig iptables off
#修改httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName www.example.com:80/g' /usr/local/Apache2/conf/httpd.conf
#启动服务
/usr/local/Apache2/bin/apachectl start
#添加开机自启
echo "/usr/local/Apache2/bin/apachectl start" >>/etc/rc.d/rc.local

你可能感兴趣的:(shell脚本一键安装二进制Apache)