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

相关推荐

  • AWK小记

    gawk – pattern scanning and processing language 基本用法:gawk [options] ‘program’ FILE … program: PATTERN{ACTION STATEMENTS} 语句之间用分号分隔 print, printf 选项: -F:指明输入…

    2018-01-16
  • 马哥教育网络班N22期+第6周课程练习

    一、总结vim编辑器的使用方法 vim文本编辑器 全屏编辑器,模式化编辑器 vim的教程文件命令:vimtutor vim /path/to/somefile vim模式: 编辑模式(命令模式),默认模式 输入模式 末行模式 内置的命令行接口; 模式转换: 编辑模式—>输入模式: i:insert, 在光标所在处前方输入,转为输入模式 a:append…

    Linux干货 2016-10-09
  • rpm软件包管理

    软件包管理 软件运行环境 API   应用程序开发接口 ABI   二进制接口 Rpm包命名方式 Name-version-release-arch-rpm 例如 zziplib-devel-0.13.162-5.el7.i686.rpm zziplib :主包名 dewel:次包名 0.13.162: 主版…

    Linux干货 2016-08-24
  • LAMP基于编译安装方式实现(httpd与php以fastcgi方式结合)3

    概述     在某些现有rpm包不能满足需求的时候,可能需要编译安装LAMP环境,本篇就介绍下php与httpd结合方式为fastcgi方式结合时的编译安装,同时,由于httpd与php以module方式结合时,仅是编译选项有所差别,故也会简单说明下编译选项的差异 环境     CentOS7系统,…

    Linux干货 2016-10-17
  • Linux进程管理常用命令(一)

    Linux系统上的进程查看及管理工具:     pstree, ps, pidof, pgrep, top, htop, glances, pmap, vmstat, dstat,kill,job,bg,fg, nohup, nice, renice, killall,…     Centos 5: Sys…

    Linux干货 2017-01-05
  • 第三周作业

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 [root@UncleZ ~]# who | cut -d' ' -f1 | uniq -c 2、取出最后登录到当前系统的用户的相关信息。 [roo…

    Linux干货 2016-12-17