自动编译安装Apache脚本

自动编译安装Apache脚本,Linux系统版本不同,具体信息要查看日志进行对应的处理,本脚本安装Apache2.4.9

#!/bin/bash
#function:Source code compile and install Apache
#author:signal
#filname:Install_Apache.sh
#date:2018-03-16
#version:1.0
echo -e “Follow the prompts:\n\t1:Check if Apache is installed\n\t2:Download Apache source package\n\t3:Compile and install\n\t”
cpu=`lscpu | sed -n ‘4p’ | awk ‘{print $2}’`
dir=$PWD
dir1=”/data/httpd”
dir2=”/etc/httpd24″
Chenk(){
rpm -q httpd &>/dev/null
if [ $? -eq 0 ];then
echo “Apache is already installed”
else
echo “Apache is not installed,please continue,Re-execute the script 2”
fi
}
Download(){
echo “============================================================”
dir=$PWD
[ ! -d $dir/httpd_tmp ] && mkdir -p ${dir}/httpd_tmp
cd ${dir}/httpd_tmp && wget http://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.29.tar.gz &>/dev/null
[ $? -eq 0 ] && echo “Apache is Download” || echo “download failed,please check your network,Downloading”
cd ${dir}/httpd_tmp && tar xf http* && rm -f *.tar.gz && echo “Decompression succeeded”
}
Cinstall(){
#/usr/bin/yum -y groupinstall “development tools” && yum -y install apr-devel apr-util-devel pcre-devel &>/dev/null
#if [ $? -eq 0 ];then
# echo “Compiled dependencies and related tools have been installed successfully”
#fi
echo “============================================================”
[ ! -d $dir1 ] && mkdir -p $dir1
[ ! -d $dir2 ] && mkdir -p $dir2
#cd ${dir}/httpd_tmp/ && rm -f *.tar.gz
cd ${dir}/httpd_tmp/http*
./configure –prefix=/data/httpd –sysconfdir=/etc/httpd24 &>${dir}/fail.txt
if [ $? -eq 0 ];then
echo “configure successfully”
else
echo “configure failed”
exit 1
fi
make -j $cpu &>${dir}/failmake.txt
if [ $? -eq 0 ];then
echo “make successfully”
else
echo “make failed”
exit 1
fi
make install &>${dir}/failaaa.txt
if [ $? -eq 0 ];then
echo “mkae install successfully”
echo “PATH=${dir1}/bin:$PATH” > /etc/profile.d/httpd24.sh
source /etc/profile.d/httpd24.sh
else
echo “make install failed”
exit 1
fi

}
read -p “Please input your number: 1)Check install Apache 2)download apache 3) Compile and install apache ” num
case $num in
1)
Chenk
;;
2)
Download
;;
3)
Cinstall
;;
*)
echo “Please enter again”
;;
esac

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/92563

(0)
SignalSignal
上一篇 2018-03-17 17:23
下一篇 2018-03-17 19:44

相关推荐

  • Storm集群安装详解

    storm有两种操作模式: 本地模式和远程模式。 本地模式:你可以在你的本地机器上开发测试你的topology, 一切都在你的本地机器上模拟出来;  远端模式:你提交的topology会在一个集群的机器上执行。 本文以Twitter Storm官方Wiki为基础,详细描述如何快速搭建一个Storm集群,其中,项目实践中遇到的问题及经验总结,在相应章…

    Linux干货 2015-04-04
  • Linux下find命令的使用

    为什么要使用find命令?     Linux系统中有着成千上万的文件,如果你想要找到自己想要的文件,一款查找软件是必不可少的,而locate是根据其生成的数据库进行查找,虽然速度会略快,但非实时查找,有些新的文件或目录是匹配不到的,而且locate是模糊匹配,而find命令为实时查找,且为精确匹配,如果你对目录的权限…

    Linux干货 2016-08-18
  • 系统管理之程序包管理(二)yum详解

    系统管理之程序包管理(二)yum详解:     上节向大家介绍了程序包管理的理论和rpm命令的使用,本篇文章接着向大家介绍rpm的前端使用工具,方便大家更快捷的管理,使用rpm包,提高工作效率。 一 概论: Centos:yum,dnf 两个rpm前端工具 YUM :yellow dog, Yellowdog,Upda…

    Linux干货 2016-08-24
  • SDCC 2017互联网运维开发实战峰会上海站

    3月17日-19日,由CSDN重磅打造的互联网运维开发实战峰会、数据库核心技术与应用实战峰会和互联网应用 架构实战峰会将在上海举行。 作为SDCC 2017(中国软件开发者大会)系列技术峰会的一部分,秉承干货实料(案例)的内容原则。 这三场峰会将邀请业内顶尖的架构师和技术专家,共同探讨运维工具研发与实践、运维自动化系统的构建、大数据与运维…

    Linux干货 2017-02-11
  • puppet进阶管理之终极应用

         上一篇博客写了puppet操作file、cron、user、group、exec基础资源的使用,连接地址为 http://www.178linux.com/13990  这次实验puppet的操作Package、Server和puppet的特殊资源属性Metaparameters。 回顾下…

    Linux干货 2016-04-12