自动编译安装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

相关推荐

  • find可以这么用

    在工作中不可或缺的工具find:查找系统中的各种文件,对查找的文件进行操作,这就是find的作用。进入正题: 1、查找下系统中有一下系统中有几个文件叫issue的     [root@localhost private]#find / -name issue      …

    Linux干货 2017-03-05
  • 基础网络配置

    配置文件: /etc/ude /proc/sys/net/ipv4/ip_forward /etc/sysconfig/network-scripts/ifcfg-IFACE 网络配置文件 /etc/sysconfig/network-scripts/route-IFACE 路由配置文件 配置文件里的设置: DEVICE:此配置文件应用到的设备 HWADDR…

    Linux干货 2017-05-08
  • rsyslog配置详解,结合mysql+loganalyzer展现

        环境:Centos7.2 前言:系统日日夜夜不停地运行着,有这么一个守护进程,兢兢业业地不断记录它运行产生的日志,有不起眼的闲言碎语,值得管理员撇一眼的系统报错,也默默地接收来自进程的严厉警告,甚至在内核崩溃前夕,同样不遗余力记录着当时发生的情形。他是无言的记录者,没有特别的修辞,但他的记录的文字却掷地有声。本…

    系统运维 2016-10-25
  • Gdevops 2017全球敏捷运维峰会【上海站】

    Gdevops-2017全球敏捷运维峰会-上海将于7月7日举行,活动家提供Gdevops 2017全球敏捷运维峰会【上海】在线报名服务。 峰会介绍 Introduction 全球敏捷运维峰会 数据已经成为企业的核心竞争力!谁掌控数据、更好的利用数据、实现资产化,谁就会真正率先进入大数据时代。 中国数据资产管理峰会DAMS2017,连续三年站在数据时…

    Linux干货 2017-06-27
  • Linux-系统启动的基本过程 以及相关破环修复实验。

    这章简单描述下系统的启动流程,主要以破环修复实验为主: 系统启动基本过程:       Linux系统启动过程大致按照如下步骤进行(这是一个简述):        第一阶段:BIOS启动引导阶段;       …

    2017-07-10