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

相关推荐

  • WEB 常见故障与处理

    一、应用故障 HTTP 502 故障 502 Bad Gateway 故障检测: 首先定位到前端故障服务器节点,在前端服务器(Telnet)上访问后端服务端口响应时间。如发现响应时间超时>10s。说明后端应用程序出现故障。需要到后端服务器查看,并查明情况。 PS:HTTP 502 Bad Gateway 故障一般分为以下2种情况: 网络问题:前端无法连…

    2016-06-03
  • 一起学DHCP系列(二)三种途径

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://jeffyyko.blog.51cto.com/28563/162176 《一起学DHCP》系列第二节。      和WINS服务类似,DHCP大体上也由两部分组成,DHC…

    Linux干货 2015-03-25
  • bash脚本进阶

    case  变量引用  in PAT1)分支1 ;; PAT2)  分支2 ;; … *) 分支n ;; esac case支持glob风格的通配符:   *:任意长度任意字符: ?:任意单个字符: [ ]:指定范围内的任意单个字符: a|b:a或b function:函数   &nbs…

    Linux干货 2017-05-21
  • Linux磁盘与文件系统管理的一些命令

    fdisk fdisk命令用于观察硬盘实体使用情况,也可对硬盘分区。它采用传统的问答式界面,而非类似DOS fdisk的cfdisk互动式操作界面,因此在使用上较为不便,但功能却丝毫不打折扣。 输入m列出可以执行的命令 p:显示磁盘分区表 n:new,新建分区 d:delete,删除分区 t:更改系统类型 l:列出已知分区类型 w:保存并退出 q:不保存退出…

    Linux干货 2017-04-23
  • N25-第七周作业

    1、创建一个10G分区,并格式为ext4文件系统;    (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;     ~]# fdisk /dev/sda  (n, +10G 创建10G分区,w保存退出)   &nbsp…

    Linux干货 2017-01-22
  • 通络通信

    网络详解: 网络的osi层次结构: 物理层: 以太网规定,连入网络的所有设备,都必须具有”网卡”接口。数据包必须是从一块网卡,传送到另一块网卡。 网卡的地址,就是数据包的发送地址和接收地址,这叫做MAC地址。 每块网卡出厂的时候,都有一个全世界独一无二的MAC地址,长度是48个二进制位,通常用12个十六进制数表示。 前6个十六进制数是厂商编号,后6个是该厂商…

    Linux干货 2016-09-02