自动编译安装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)
上一篇 2018-03-17 17:23
下一篇 2018-03-17 19:44

相关推荐

  • 马哥教育网络班20期+第五周博客作业

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; ]# grep  "^[[:space:]]\+" /boot/grub/grub.conf 2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行; ]#…

    Linux干货 2016-07-12
  • Centos 7 DNS配置及理论详解

    DNS是什么及BIND讲解内容 域名系统(英文:Domain Name System,缩写:DNS)是internet的一项服务。它作为将域名和IP地址相互映射服务,能够使人更方便地访问互联网。DNS使用TCP和UDP端口53。当前,对于每一级域名长度的限制是63个字符,域名总长度则不能超过253个字符。讲解内容:    DNS名称解析方…

    Linux干货 2016-04-25
  • Linux 文 本 处 理 工 具

    Linux 文 本 处 理 工 具 一.学习大纲: ◎各种文本工具来查看、分析、统计文本文件 文件内容查看工具:cat, tac,rev,more,less 文件截取:head和tail 按列抽取:cut,paste 分析文本的工具:wc , sort , uniq,diff和patch 命令使用练习题 ◎文本过滤与处理工具: grep与正则表达式…

    Linux干货 2016-08-05
  • Centos7 PHP-FPM源码安装

    PHP-FPM源码安装 安装必要组件 yum install -y openssl-devel traceroute libtool unzip gcc gcc-c++ autoconf net-snmp-devel vim wget sysstat lrzsz  man tree mysql-devel ntpdate rsync libxml2…

    系统运维 2016-09-06
  • 正则表达与扩展正则表达

    说到正则表达式那就不得不说grep命令: 1.grep命令的作用:grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来。grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权限是所有用户。2.格式 2.命令格式 :grep [options] 3.主要参数: gre…

    2017-08-07