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

相关推荐

  • 压缩、解压缩及归档工具

    压缩、解压缩及归档工具 一、杂项知识整理 1、find -iname 忽略大小写;     -inum 查找指定inode号的文件;  find 在有条件判断的时候,如果不加括号,最后的命令会被当成以为第二个条件之后的:例 [root@localhost shelltest]# find&…

    Linux干货 2016-08-18
  • 用NFS搭建wordpress让两台httpd服务同时服务

    一、博客实践作业: (1) nfs server导出/data/application/web,在目录中提供wordpress;  (2) nfs client挂载nfs server导出的文件系统至/var/www/html; (3) 客户端(lamp)部署wordpress,并让其正常访问;要确保能正常发文章,上传图片; (4) 客户端2(la…

    2017-06-07
  • fstab配置文件、swap分区,文件关联

    fstab配置文件、swap分区,文件关联,lvm 挂载点和/etc/fstab  配置文件系统体系  被mount、 fsck和其它程序使用  系统重启时保留文件系统体系  可以在设备栏使用文件系统卷标  使用mount -a 命令挂载/etc/fstab中的所有文件…

    Linux干货 2016-09-01
  • 文本工具

    本文将介绍Linux下使用Shell处理文本时最常用的工具:find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk;提供的例子和参数都是最常用和最为实用的

    2017-11-25
  • MongoDB

    Edit MongoDB 手册 MongoDB 手册 第一章 Introduction MongoDB入门学习目录(建议) Databases Collections Documents 第二章 部署安装 1. Import the MongoDB public key 2. Configure the package management system (…

    Linux干货 2017-04-08
  • N25-第五周作业

    第五周作业 1、显示当前系统上root、fedora或user1用户的默认shell; grep "^\(root|fedora|user1\)" /etc/passwd | cut -d: -f7 2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello(); grep "…

    Linux干货 2017-02-14