Shell script automatically compiles and installs Apache

Source: Internet
Author: User

Shell script automatically installs Apache for CentOS

#!/bin/bash##################################################### #Create  date 2018.4.10#Author:  wansheng#function: shell script install apache2.4#email: [email protected]  #System:  linux centos-7#################################################### #if  [  $UID  -ne 0 ];then        please use root  user running script!!         exit 1fi# Download the installation package 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 '. " $ "." $ Zlib_dir= ' echo  $zlib _name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ "." $ Pcre_dir= ' echo  $pcre _name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ ' openssl_dir= ' echo  $openssl _name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ "." $ Libxml2_dir= ' echo  $libxml 2_name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ "." $ Apr_dir= ' echo  $apr _name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ "." $ Apr_util_dir= ' echo  $apr _util_name|awk -f "[/]"   ' {print  $NF} ' |awk -f "[.]"   ' {print $1 '. " $ "." $ ################################# #安装目录及服务目录 ############################# #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-dev Ellualua-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 &Nbsp;  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  Congratulations, Apache-2.4 installation Success \033[0m"}main () {Package_installapr_ Installpcre_installapache_installapache_optimize}main


Shell script automatically compiles and installs Apache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.