自动编译安装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编程之数组及环境变量

    数组 变量:存储单个元素的内存空间 数组:存储多个元素的连续的内存空间,相当于多个变量的 集合 索引:编号从0 声明数组: declare -a ARRAY_NAME declare -A ARRAY_NAME:关联数组 1.declare  -a menu  menu[0]=beef  menu[1]=chicken menu…

    Linux干货 2016-08-29
  • 马哥教育网络班20期第3周课程练习

    答: 1、 [root@totooco ~]# who | cut -c1-9 | sort -u 2、 [totooco@totooco ~]$ who | cut -c1-9 | head -1 3、 [root@totooco ~]# cat /etc/passwd | cut -d: -f7 | grep -v /sbin/nologin | sor…

    Linux干货 2016-06-23
  • N27_网络班第九周作业

    N27_网络班第九周作业 1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现 #!/bin/bash loginuser=`grep -v ‘/sbin/nologin’ /etc/passwd | wc -l` nologin=`grep …

    2017-10-10
  • Linux中的权限修改指令及正则表达式

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没有任何访问权限 [root@centos6 ~]# cp -r /etc/skel/ /home/tuser1 [root@centos6 ~]# ls -la&…

    Linux干货 2016-10-24
  • 文件查找命令

    查找命令:local,find local:非实时查找,通过系统数据库进行搜索,无法查找到在系统数据库更新后创建的文件,但是查找速度快,模糊查找(不仅会查找到文件名还会找到文件全路径) find:在硬盘上进行实时搜索,速度较慢,但是可以找到当前所有的数据 系统数据库在   /var/lib/mlocate/mlocate.db 系统一般会…

    Linux干货 2016-08-16
  • grep 整理

    grep: Linux上文本处理三剑客 grep:文本过滤(模式:pattern)工具;  grep: Global search REgular expression and Print out the line. 作用:文本搜索工具,根据用户指定的“模式”…

    Linux干货 2016-10-09