自动编译安装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
下一篇 2018-03-17

相关推荐

  • linux系统基础目录结构及功能说明

    linux系统基础目录结构及功能说明 [root@localhost /]# ls bin boot dev etc home host lib lib64 media mnt opt proc root run sbin srv sys tmp usr var /bin:所有用户可用的基本命令程序文件;/sbin:供系统管理使用的工具程序;/boot:引导…

    Linux干货 2018-03-04
  • N25期第三周作业

    1.列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可 who|awk ‘{print $1}’|sort -u 2.取出最后登录到当前系统的用户的相关信息 last -1 3.取出当前系统上被用户当作其默认shell的最多的那个shell cat /etc/passwd|awk -F: ‘{print $NF}’|sort…

    Linux干货 2016-12-12
  • Linux系统程序包的管理-Yum及编译安装

          Yum 是通过分析RPM的标头数据后,根据各软件的依赖关系制作出有依赖关系时的的解决方案,然后可以自动处理软件的依赖性问题,以解决软件安装或移除与升级的问题。       由于发行版必须要先释放软件,然后将软件放置于yum服务器上面,以提供用户端用来安装与升…

    2017-05-02
  • 【原创】RHEL7-PPTP-VPN-Server排错

    第一次写博客,明显不知道如何下笔。     昨天6月21日,突然发现往日运行一切正常的pptpvpn服务器怎么也连不上了,错误代码是619。这个错误代码以前并没有见过,于是上google查了一下资料,据说有几种可能: 1,路由器或防火墙干掉了tcp1723; 2,电脑协议栈问题; 3,拨号连接的认证选项有问题; &nb…

    Linux干货 2016-06-23
  • 来到马哥的第一天

    找到马哥之后的故事

    Linux干货 2018-03-26
  • shell进阶之循环

    循环执行,将某代码段重复运行多次

    重复运行多少次:

    循环次数事先已知

    循环次数事先未知

    有进入条件和退出条件

    for, while, until

    Linux干货 2017-12-24