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

相关推荐

  • shell编写的linux命令练习工具

    linux常用命令加选项,有成百上个,仅仅靠背诵忘记得太快,所以写了此脚本,便于对linux命令的练习,希望能帮助到大家。 运行脚本效果如下: 上边两图一个是运行脚本时的截图,另一个为题库的格式(@做分隔符,所以如果题目中有@一定要替换掉) 下面附上源码 #!/bin/bash#版本号:1.0 #作者:Mr.L #WX:504498722FILE=/root…

    2017-03-19
  • Python 课堂笔记

    第二天

    Linux干货 2018-03-21
  • centos6启动故障及修复

    前言 前文中我们熟悉了linux的启动流程,如果在启动过程中文件丢失或者损坏了怎么办呢?难道只有重装系统这一条路吗?那我们不是成了普通网管了吗?作为专业的运维工程师,我们需要掌握如何快速修复系统启动。 实验1: 破坏/boot/grup/下的文件——-stage2 阶段  不影响启动  mv /boot/grub …

    2017-09-03
  • python Django分页

    自定义html_helper.py  —>  Page_helper类 #coding:utf-8 from django.utils.safestring import mark_safe class Page_Helper(object):    …

    Linux干货 2016-08-22
  • LINUX-echo命令

    echo命令:回显         语法:echo [-neE][字符串]     说明:echo会将输入的字符串送往标准输出。输出的字符串间         以空白字符隔开,并在最后加上换行号。   &nbs…

    Linux干货 2017-05-22
  • Memcached + MSM 实现Tomcat Session保持

    Memcached + MSM 实现Tomcat Session保持 tomcat memcached 前言 Memcached介绍 MSM介绍 实验拓扑 实验环境 实验步骤 安装配置Tomcat 安装配置Nginx负载均衡 安装配置Memcached + MSM 总结 前言 上篇文章我们实现了session sticky和session clus…

    2016-04-22