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

相关推荐

  • 分析命令中含有e2fs

    分析命令中含有e2fs 目  录 1、mke2fs  2、tune2fs 3、dump2fs 4、e2fsck 这周学到了几条命令,超级纳闷为什么这些命令都带有e2fs ,看不懂。毕竟在我的认知中linux的命名大部分都是见名知义,例如history(查看历史命令),fdisk (分区),反观这些命令很长而且还是奇怪的…

    Linux干货 2017-08-20
  • 堡垒机-麒麟开源堡垒机苹果 Mac支持版本发布

      近日,麒麟开源堡垒机团队开发测试了支持Mac OS苹果操作系统的Web插件,苹果系统用户可以直接和Windows用户一样,登录到Web平台,使用点击的方式调动运维工具并且登录到目标系统进行操作运维。 Mac OS插件支持ssh、telnet、rdp、vnc、x11、sftp、ftp、应用发布等所有协议。   注:麒…

    Linux干货 2016-05-19
  • 第七周作业

    查看作业内容请移步此链接:http://www.cnblogs.com/wangenzhi/p/6403568.html

    Linux干货 2017-02-15
  • 马哥教育网络班21期-第九周课程练习

    第九周作业 1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash # declare -i nologin=0 declare -i other=0   &n…

    Linux干货 2016-09-19
  • iptables实战笔记一

    iptables实战 1.开启防火墙 systemctl start firewalld 2.清空所有的默认规则,我们自己定义自己的规则 iptables -F 查看此时的iptables iptables -nL Chain INPUT (policy ACCEPT) target prot opt source destination Chain FOR…

    Linux干货 2017-06-13
  • 作业:0803日

    1:三种权限rwx对文件和目录的不同意义:       对文件: r:能够查看文件内容 w:修改文件内容 x:执行文件,通常文件的执行权限能够发起一个进程       对目录: r: 能够cd进目录,使用ls查看目录内的文件列表 w: 能够…

    Linux干货 2016-08-05