分享web开发知识

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

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

shell脚本自动编译安装Apache

发布时间:2023-09-06 01:55责任编辑:白小东关键词:shell编译
shell脚本自动安装Apache,适用于CentOS

#!/bin/bash######################################################Create date 2018.4.10#Author: wansheng#Function: shell script install apache2.4#Email: 1447646759@qq.com #System: Linux CentOS-7#####################################################if [ $UID -ne 0 ];then        please use root user running script!!        exit 1fi#下载安装包apache_name="https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.33.tar.gz"zlib_name="https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz"apr_name="https://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz"apr_util_name="https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz"pcre_name="https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz"openssl_name="https://www.openssl.org/source/openssl-1.1.1-pre3.tar.gz"libxml2_name="http://distfiles.macports.org/libxml2/libxml2-2.9.7.tar.gz"#安装包目录定义apache_dir=`echo $apache_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`zlib_dir=`echo $zlib_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`pcre_dir=`echo $pcre_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2}'`openssl_dir=`echo $openssl_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`libxml2_dir=`echo $libxml2_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`apr_dir=`echo $apr_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`apr_util_dir=`echo $apr_util_name|awk -F"[/]" '{print $NF}'|awk -F"[.]" '{print $1"."$2"."$3}'`##################################安装目录及服务目录##############################apache_install_dir=/server/application/${nginx_dir}apache_server_dir=/usr/local/apche[ ! -d /root/soft ] && mkdir -p /root/soft[ ! -d /server/application ] && mkdir -p /server/applicationpackage=(wgetcurlgccgcc-c++libxml2-develgd-develGeoIPGeoIP-develperlperl-develperl-ExtUtils-Embedlibxsltlibxslt-devellsofmaketreelrzszexpatexpat-devellualua-developensslopenssl-devel)#安装包software=($zlib_name$apache_name$pcre_name$openssl_name$libxml2_name$apr_name$apr_util_name)############################################################################function apache_check(){if [ $? -ne 0 ];then        echo $_    echo "please check error!!!!!"        exit 2fi}#########################################################function package_install(){yum -y groupinstall "Development Tools"for package_i in ${package[*]}do        rpm -ql $package_i    if [ $? -ne 0 ];then        yum -y install $package_i        echo $package_i    else        continue        fidonecd /root/softfor software_i in ${software[*]}do    echo $software_i    software_ls=`echo $software_i |awk -F"[/]" '{print $NF}'`        if [ -f $software_ls ];then                tar zxvf $software_ls        else                wget $software_i                tar zxvf $software_ls        fidone}#########################################################function apr_install(){if [ ! -d /usr/local/apr ];then    cd /root/soft/$apr_dir    ./configure --prefix=/usr/local/apr    apache_check    make    apache_check    make install    apache_check    cd /root/soft/$apr_util_dir    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-crypto    apache_check    make    apache_check    make install    apache_check    echo 2222else    echo 111fi}function pcre_install(){if [ ! -d /usr/local/pcre ];then        cd /root/soft/$pcre_dir        ./configure --prefix=/usr/local/pcre --enable-utf8        apache_check        make        apache_check        make install        apache_check    echo 2222else    echo 111fi}function apache_install(){cd /root/soft/$apache_dir./configure --prefix=/server/application/apache-2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-z=/root/soft/zlib-1.2.11 --with-libxml2=/root/soft/libxml2-2.9.7 --with-ssl --with-curl --with-mpm=prefork --enable-so --enable-authnz-fcgi --enable-file-cache --enable-cache --enable-cache-disk --enable-cache-socache --enable-cgi --enable-rewrite --enable-mpms-shared --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-fcgi --enable-proxy-scgi --enable-proxy-express --enable-proxy-hcheck --enable-slotmem-shm --enable-slotmem-plain --enable-ssl --enable-ssl-staticlib-deps --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-htdbm --enable-static-ab --enable-static-logresolve --enable-unixd --enable-expires --enable-authn-dbm --enable-lua --enable-luajit --libdir=/usr/lib64apache_checkmakeapache_checkmake installapache_check}function apache_optimize(){ln -s /server/application/apache-2.4 /usr/local/apachesed -i 's/#Server.*80/ServerName localhost:80/g' /server/application/apache-2.4/conf/httpd.conf/usr/local/apache/bin/apachectl -k startapache_checkss -tunl|grep 80curl -I -s http://127.0.0.1|awk NR==1apache_checkecho -e "\033[32;1m 恭喜您,Apache-2.4安装成功\033[0m"}main(){package_installapr_installpcre_installapache_installapache_optimize}main


shell脚本自动编译安装Apache

原文地址:http://blog.51cto.com/13416785/2118717

知识推荐

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