分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

httpd 一键编译安装脚本(centos6&7_httpd2.2&2.4)

发布时间:2023-09-06 02:27责任编辑:赖小花关键词:http编译

httpd 一键编译安装脚本(centos6&7_httpd2.2&2.4)


说明

此安装脚本中涉及的服务启动脚本需要单独编写

httpd_install.sh

#!/bin/bash# *****************************************************# author ????: shchangming# date ??????: 2018-06-06# QQ ????????: 414945814# Description: this script is to install http one shoot# *****************************************************CENTOS_VER=`egrep -wo ‘[0-9]+‘ /etc/centos-release | head -n 1`httpd_list() {echo "which httpd version would you like to install:**********************************************httpd-2.2.18httpd-2.2.20httpd-2.2.26httpd-2.4.37or you can input other versionquit | q**********************************************"}BASE_DIR="/web"check_pre() { ???if [ -d ${BASE_DIR}/${1} ];then ???????echo "${1} has been installed!" ???????exit ???fi}change_yum() { ???mkdir /etc/yum.repos.d/old ???mv /etc/yum.repos.d/*.repo ?/etc/yum.repos.d/old ???wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-${CENTOS_VER}.repo ???wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-${CENTOS_VER}.repo}env_pre() { ???### 安装其他必要的依赖 ???yum clean all ???yum groupinstall "Development Tools" -y ???DEP_LIST="gcc glibc apr-devel apr-util-devel pcre-devel openssl-devel expat-devel make" ???for dep in $DEP_LIST;do ???????????rpm -q "${dep}" &> /dev/null || yum install $dep -y ???done}get_http_package() { ???HTTP_VER=$1 ???[ -f ${HTTP_VER}.tar.bz2 ] || wget -t 5 -w 10 https://archive.apache.org/dist/httpd/${HTTP_VER}.tar.bz2 ???tar xf ${HTTP_VER}.tar.bz2 &>/dev/null || exit}centos6_install_httpd_24() { ???INSTALL_DIR="$1" ???[ ! -d ${BASE_DIR} ] && mkdir -p ${BASE_DIR} ???./configure --prefix=${BASE_DIR}/${INSTALL_DIR} ????--enable-so ????--enable-ssl ????--enable-cgi ????--enable-rewrite ????--with-zlib ????--with-pcre ????--with-included-apr ????--enable-modules=most ????--enable-mpms-shared=all ????--with-mpm=prefork && ????make -j 4 && make install && ????ln -s ${INSTALL_DIR} ${BASE_DIR}/httpd ???id apache || useradd -r -s /sbin/nologin apache ???cp ${BASE_DIR}/httpd/conf/httpd.conf{,.bak} ???sed -ri "/^(User|Group)/s/daemon/apache/" ${BASE_DIR}/httpd/conf/httpd.conf ???sed -ri "/^#ServerName/s/^#//" ${BASE_DIR}/httpd/conf/httpd.conf}centos6_or_7_install_httpd_22_or_24() { ???INSTALL_DIR="$1" ???[ ! -d ${BASE_DIR} ] && mkdir -p ${BASE_DIR} ???./configure --prefix=${BASE_DIR}/${INSTALL_DIR} ????--enable-so ????--enable-ssl ????--enable-cgi ????--enable-rewrite ????--with-zlib ????--with-pcre ????--enable-modules=most ????--enable-mpms-shared=all ????--with-mpm=prefork && ????make -j 4 && make install && ????ln -s ${INSTALL_DIR} ${BASE_DIR}/httpd ???id apache || useradd -r -s /sbin/nologin apache ???cp ${BASE_DIR}/httpd/conf/httpd.conf{,.bak} ???sed -ri "/^(User|Group)/s/daemon/apache/" ${BASE_DIR}/httpd/conf/httpd.conf ???sed -ri "/^#ServerName/s/^#//" ${BASE_DIR}/httpd/conf/httpd.conf}main() {httpd_listread -p "please select version:" ?http_versioncase "$1" in ???6) ???????case "$http_version" in ???????????httpd-2.4.[2-3][6-7]) ???????????????check_pre $http_version ???????????????change_yum ???????????????env_pre ???????????????get_http_package $http_version ???????????????APR_DEPS="apr-1.6.5 apr-util-1.6.1" ???????????????for apr_dep in ${APR_DEPS};do ???????????????????[ -f ${apr_dep}.tar.bz2 ] || wget -t 5 -w 10 http://mirrors.tuna.tsinghua.edu.cn/apache/apr/${apr_dep}.tar.bz2 ???????????????????tar xf ${apr_dep}.tar.bz2 &>/dev/null ???????????????????if [ $? -ne 0 ];then ???????????????????????echo "${apr_dep}.tar.bz2 download failed";exit ???????????????????fi ???????????????done ???????????????cp -av apr-1.6.5 httpd-2.4.37/srclib/apr ???????????????cp -av apr-util-1.6.1 httpd-2.4.37/srclib/apr-util ???????????????cd $http_version ???????????????centos6_install_httpd_24 $http_version ???????????????echo export PATH=${BASE_DIR}/httpd/bin:‘$PATH‘ > ?/etc/profile.d/httpd24.sh ???????????????. /etc/profile.d/httpd24.sh ???????????????grep "MANPATH ${BASE_DIR}/httpd/man" /etc/man.config || echo "MANPATH ${BASE_DIR}/httpd/man" >> /etc/man.config ???????????????httpd -t && httpd ???????????????### 自定义启动脚本 /etc/rc.d/init.d/httpd24 (参考httpd-2.2的服务脚本) ???????????????if [ -f ${BASE_DIR}/init.d/httpd24 ];then ???????????????????chmod +x ${BASE_DIR}/init.d/httpd24 ???????????????????chkconfig --add httpd24 ;chkconfig --list httpd24;chkconfig httpd24 on;chkconfig --list httpd24 ???????????????fi ???????????????;; ???????????httpd-2.2.[1-2-3][0-1-2-3-4-5-6-7-8-9]) ???????????????check_pre $http_version ???????????????change_yum ???????????????env_pre ???????????????get_http_package $http_version && cd $http_version ???????????????centos6_or_7_install_httpd_22_or_24 $http_version ???????????????echo export PATH=${BASE_DIR}/httpd/bin:‘$PATH‘ > ?/etc/profile.d/httpd22.sh ???????????????. /etc/profile.d/httpd22.sh ???????????????grep "MANPATH ${BASE_DIR}/httpd/man" /etc/man.config || echo "MANPATH ${BASE_DIR}/httpd/man" >> /etc/man.config ???????????????httpd -t && httpd ???????????????### 自定义启动脚本 /etc/rc.d/init.d/httpd22 (参考httpd-2.2的服务脚本) ???????????????if [ -f ${BASE_DIR}/init.d/httpd22 ];then ???????????????????chmod +x ${BASE_DIR}/init.d/httpd22 ???????????????????chkconfig --add httpd22 ;chkconfig --list httpd22;chkconfig httpd22 on;chkconfig --list httpd22 ???????????????fi ???????????????;; ???????????quit|q) ???????????????echo "Bye" && exit ???????????????;; ???????????*) ???????????????echo "do not sport this version" && exit ???????????????;; ???????esac ???????;; ???7) ???????case "$http_version" in ???????????httpd-2.2.[2][6-7-8-9]|httpd-2.4.[1-2-3-4][0-1-2-3-4-5-6-7-8-9]) ???????????????check_pre $http_version ???????????????change_yum ???????????????env_pre ???????????????get_http_package $http_version && cd $http_version ???????????????centos6_or_7_install_httpd_22_or_24 $http_version ???????????????echo export PATH=${BASE_DIR}/httpd/bin:‘$PATH‘ > ?/etc/profile.d/httpd24.sh ???????????????. /etc/profile.d/httpd24.sh ???????????????grep "MANDATORY_MANPATH ${BASE_DIR}/httpd/man" /etc/man_db.conf || echo "MANDATORY_MANPATH ${BASE_DIR}/httpd/man" >> /etc/man_db.conf ????????????????httpd -t && httpd ???????????????### 自定义启动脚本 /etc/rc.d/init.d/httpd24 (参考httpd-2.2的服务脚本) ???????????????if [ -f ${BASE_DIR}/init.d/httpd24 ];then ???????????????????chmod +x ${BASE_DIR}/init.d/httpd24 ???????????????????chkconfig --add httpd24 ;chkconfig --list httpd24;chkconfig httpd24 on;chkconfig --list httpd24 ???????????????fi ???????????????;; ???????????quit|q) ???????????????echo "Bye" && exit ???????????????;; ???????????*) ???????????????echo "do not sport this version" && exit ???????????????;; ???????esacesac}main $CENTOS_VER

本文链接:https://www.cnblogs.com/shichangming/p/10153464.html

httpd 一键编译安装脚本(centos6&7_httpd2.2&2.4)

原文地址:https://www.cnblogs.com/shichangming/p/10153464.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved