Linux Automatic installation Script

Source: Internet
Author: User
Tags openssl

The kernel parameters of the tested Linux are Linux rhel5 2.6.18-238.el5

System is red Hat Enterprise Linux Server Release 5.6

The related APR,APU,PCRE,OPENSSL package dependency scripts are not considered, and the dependent packages are already installed by default.

Script installation operation note and features:

1, by default in the current script file in the same directory as the creation of the Apache program directory, the support configuration directory, the script can be run prompt modification, you can directly modify the script, directly modify the default configuration in the script.

2, the default configuration of the Apr,apu,pcre,openssl installation directory, is not supported during the installation process modification.

3, support the use of different httpd,apr,apu,pcre and OpenSSL installation package, in the installation process, as prompted to enter the installation package name, and directly modify the script's default configuration

4, optional installation of HTTP and HTTPS, in the installation process as prompted to enter a choice, select the default installation will install HTTPS.

5, support the configuration of different Apache compilation parameters, can be prompted during the installation process, or directly modify the script's default configuration parameters.

6, support to modify the prompt time during the installation process, can be modified in the script.

#!/bin/bash#------------------------------------------------------------------------##                           written by jm on 2016.02.25                     ##                                                                            ##------------------------------ ------------------------------------------#dir = ' pwd ' #apache安装时除apr, Apu,pcre, Default installation configuration parameters outside the OpenSSL installation path apadefultprefix= "--with-mpm=worker --enable-rewrite --enable-module=so --enable-proxy --enable-proxy-ajp -- Enable-forward --enable-proxy-connect --enable-proxy-http "#安装过程中所有提示语的显示时间, Seconds hinttime=15# SETHTTPDDEFAULTNAME,HTTPD Install package default name configuration Httpddefaultname=httpd-2.4.16.tar.gz#setaprdefaultname, Apr Install package default name configuration Aprdefaultname=apr-1.5.2.tar.gz#setapudefaultnam,apu Install package default name configuration apudefaultname=apr-util-1.5.4.tar.gz# Setpcredefaultname,pcre Install package default name configuration Pcredefaultname=pcre-8.36.zip#setopenssldefaultname, OpenSSL installation package default name configuration Openssldefaultname=openssl-1.0.2f.tar.gz#set apachedefaultdir, Apache default installation path configuration apachedefaultdir= $dir/apache#set apachedir, set Apache installation path if read -t  $hinttime  -p  "Pls enter apache dir please set the full path of the Apache installation directory such as:/home/rs/apache:"  apachedirthen     if [[  $apachedir  ==  " ]]    then         apachedir= $apachedefaultdir          echo   "apachedir is empty,would use default port  $apachedir; input is empty, will use the default directory $apachedir "    else        echo -e   "\napachedir is  $apachedir; Apache directory is $apachedir"     fielse     apachedir= $apachedefaultdir     echo -e  "\napachedir is  empty,would use default port  $apachedir; Enter is blank, the default directory $apachedir will be used fi#init apache  Interface,apache Compression Packet Decompression Initialization Interface Function httpakinit () {cd  $dirif  [ ! -f  $httppak  ] then    echo  "httpd install package not exit,pls upload!"     exit 1else    httpddir= ' echo  ' $httppak "|sed  ' s/. tar.gz$//'     tar -zxvf  $HTTPPAKFI} #set  apache pak  initialize Apche source package, Call Apache Compression Pack initialization Interface IF READ -T  $hinttime  -p  "Pls enter apache zip package name ex: httpd-2.4.16.tar.gz; Enter Apche package name such as: httpd-2.4.16.tar.gz: " httppakthen    if [[   $httppak  ==  " ]]    then         httppak= $httpddefaultname         echo  "apche pak  is empty,would use default pak  $httppak; Enter the Apche compressed package name to NULL, $httppak the default package name "         httpakinit    else         echo  "apche pak is  $httppak; Enter Apche compression package named $httppak"      httpakinit    fielse    httppak= $httpddefaultname      echo -e  "\napache pak is empty,would use default apche pak   $httppak; Enter the Apache package name $httppak "    httpakinitfi#init apr apk fuction  Initialize APR packet function Interface Function aprinit () {cd  $dirif  [ ! -f  $aprpak  ]then   echo  "Apr install  package not exit,pls upload! "    exit 1else         tar -zxvf $ Aprpak         aprdir= ' echo  ' $aprpak "|sed  ' s/.tar.gz$// "     httpddir= ' echo " $httppak "|sed  ' s/.tar.gz$//'       cd ${httpddir}/srclib         rm -rf  APR         CD&NBSP, .... /.. /         mv ${aprdir}  ${httpddir}/srclib/aprfi}# init apr pak  Initialize Apr source pack if read -t  $hinttime  -p  "pls enter  Apache zip package name ex:apr-1.5.2.tar.gz; Input Apche Compressed package name such as: apr-1.5.2.tar.gz: " aprpakthen     if [[  $aprpak  ==  " ]]    then         aprpak= $aprdefaultname         echo  "apr pak is empty,would use default pak  $aprpak; Enter the APR compressed package name to NULL, and the default package name $aprpak"         aprinit    else         echo  "apr pak is  $aprpak; Enter Apr compression package named $aprpak"          aprinit    fielse    aprpak=$ aprdefaultname    echo -e  "\napr pak is empty,would use  default apche pak  $aprpak; Enter the APR compressed package name to NULL, using the default package name $aprpak "    aprinitfi# init apu pak fuction  initializationAPU Source Packet Function Interface Function apuinit () {cd  $dirif  [ ! -f  $apupak  ]then    echo  "apu install package not exit,pls upload!"    exit 1else         tar -zxvf $ Apupak         apudir= ' echo  ' $apupak "|sed  ' s/.tar.gz$// "         apchedir= ' echo " $httppak "|sed  ' s/.tar.gz$//' '          cd ${httpddir}/srclib          rm -rf apr-util          CD&NBSP, .... /.. /         mv ${apudir}  ${httpddir}/srclib/ Apr-utilfi} #init  apu install function  Initialize APU source package if read -t  $hinttime  -p   "pls enter apu zip package name ex:apr-util-1.5.4.tar.gz; Enter the APU compression package name such as: apr-util-1.5.4.tar.gz : " apupakthen     if [[  $apupak  ==  " ]]    then         apupak= $apudefaultname         echo   "apu pak is empty,would use default pak  $apupak; Enter the APU compression package name is empty, the default package name is $ Apupak "        apuinit    else         echo  "apu pak is  $apupak; Enter the APU compression package named $apupak"          apuinit    fielse    apupak=$ apudefaultname    echo -e  "\napr pak is empty,would use  default apche pak  $apupak; Enter the APR compressed package name to NULL, using the default package name $apupak "    apuinitfi# install pcre apk, installing the Pcre function interfaceFunction pcreinstall () {cd  $dirif  [ ! -f  $pcrepak  ]then    echo  "pcre install package not exit,pls upload!"    exit 1else        unzip -o  $pcrepak         pcresrcdir= ' echo  ' $pcrepak ' |sed  ' s/.zip$//'          cd  $dir/$pcresrcdir          chmod 777 -r *        ./configure --prefix=$ apachedir/pcre && make && make install         if [[  ' echo $? '  == 0 ]]         then                 echo  "Pcre install suscces"                               else                 echo  "pcre install error,pls check!"                 exit 1         fifi} #pcre  pak init install function  Initialize Pcre source package and install if read -t  $hinttime  -p  "Pls enter pcre zip package  name ex:pcre-8.36.zip; Enter the APU compression package name such as: pcre-8.36.zip : " pcrepakthen    if  [[  $pcrepak  ==  " ]]    then         pcrepak= $pcredefaultname         echo  "Pcre pak  is empty,would use default pak  $pcrepak; Enter the Pcre compressed package name to NULL, $pcrepak the default package name "         pcreinstall    else        echo  "Pcre  pak is  $pcrepak; Enter the Pcre package named $pcrepak "         pcreinstall    fielse    pcrepak= $pcredefaultname      echo -e  "\npcre pak is empty,would use default pak  $pcrepak Enter the Pcre compressed package name to NULL, and the default package name $pcrepak "    pcreinstallfi#install openssl  APK mount OpenSSL function Interface Function opensslinstall () {cd  $dirif  [ ! -f  $opensslpak  ] then   echo  "openssl install package not exit,pls upload!"    exit 1else        tar -zxvf $ Opensslpak        opeNsslsrcdir= ' echo  ' $opensslpak ' |sed  ' s/.tar.gz$//'         CD   $dir/$opensslsrcdir         chmod 777 -R *         ./config shared --prefix= $apachedir/ssl -dopenssl_no_ heartbeats && make && make install         if [[  ' echo $? '  == 0 ]]         then                 echo  "Openssl install suscces"                                else                 echo  "Openssl install error,pls check! "                 exit 1         fifi} #openssl  pak init install function   Initialize the OpenSSL source pack and install #ssl install function include opesnsslinstall and ini  Function ,ssl Installation Interface contains Opensslinstall procedure call Function sslinstall () {if read -t  $hinttime   -p  "pls enter openssl tar.gz  package name ex:openssl-1.0.2f.tar.gz; Enter the OpenSSL compression package name such as: openssl-1.0.2f.tar.gz : " opensslpakthen    echo " ' pwd ' "     if [[  $opensslpak  ==  " ]]    then         opensslpak= $openssldefaultname          echo  "opensslpak pak is empty,would use default pak  $oPensslpak; Enter the OpenSSL package name is empty and the default package name $opensslpak "        opensslinstall     else        echo  "Opensslpak pak  is  $opensslpak; Enter the Pcre package named $opensslpak "         opensslinstall    fielse    opensslpak= $openssldefaultname      echo -e  "\nopensslpak pak is empty,would use default pak   $opensslpak; Enter the Opensslpak package name to NULL, and the default package name $opensslpak "    opensslinstallfi} #http   INSTALL INTERFACE,HTTPD Installation Function Interface Function httpdinstall () {cd  $dir/$httpddir./configure --prefix = $httpdprefix  && make && make installif [[  ' echo $? '  == 0 ]]then   echo  "Apache install suscces" else    echo  "Apache install error "   exit 1fi} #apache参数配置设定, httpd install Call Function Interface Function apacheinstall () {if read  -t  $hinttime  -p  "Pls enter httpd prefix,no need enter apachedir, Apr,apu,pcre,ssl (no input apache,apr,apu,pcre,ssl compilation path), input parameter example:--with-mpm=worker --enable-rewrite: "  httpdprefixthen    if [[  $httpdprefix  ==  ""   &&   $1 ==  "Nhttps"  ]]    then         httpdprefix= ' echo  ' $apachedir  --with-included-apr --with-included-apr-util -- with-pcre= $apachedir/pcre  $apadefultprefix "'         echo " 1, httpdprefix is empty,would use default httpdprefix  $httpdprefix; input Apache compile parameter is empty, Default parameters will be used, $httpdprefix "        httpdinstall    elif  [[  $httpdprefix ==  "  &&  $1 == "  ]]    then         httpdprefix= ' echo  ' $apachedir  --with-included-apr -- with-included-apr-util --with-pcre= $apachedir/pcre --enable-ssl --with-ssl= $apachedir/ssl  $apadefultprefix '         echo  ' 2,httpdprefix is empty, would use default httpdprefix  $httpdprefix; input Apache compile parameter is blank, default parameter will be used, $httpdprefix "         httpdinstall    elif [[  $httpdprefix  !=  ""   &&  $1 ==  "Nhttps"  ]]    then         httpdprefix= ' echo  ' $apachedir  --with-included-apr  --with-included-apr-util --with-pcre= $apachedir/pcre  $httpdprefix "'          echo  "6,httpdprefix pak is  $httpdprefix; input compilation parameter is $httpdprefix"      httpdinstall    else    httpdprefix= ' echo  ' $apachedir  -- With-included-apr --with-included-apr-util --with-pcre= $apachedir/pcre --enable-ssl -- with-ssl= $apachedir/ssl  $httpdprefix "'         echo " 3, httpdprefix  is  $httpdprefix; Input compilation parameter is $httpdprefix "    httpdinstall     fielse    if [[ $1 ==  "Nhttps"  ]]     then        httpdprefix= ' echo  ' $apachedir  -- with-included-apr --with-included-apr-util --with-pcre= $apachedir/pcre   $apadefultprefix "'         echo -e  "\n4,httpdprefix is empty,would  use default httpdprefix&nBSP, $httpdprefix; Enter the Apache compile parameter is empty, default parameters will be used, $httpdprefix "         Httpdinstall    else        httpdprefix= ' Echo   "$apachedir  --with-included-apr --with-included-apr-util --with-pcre= $apachedir/pcre  --enable-ssl --with-ssl= $apachedir/ssl  $apadefultprefix "'          echo -e  "\n5,httpdprefix is empty,would use default httpdprefix   $httpdprefix; Enter the Apache compile parameter is blank, default parameters will be used, $httpdprefix "         Httpdinstall    fifi} #安装apache, call the Apache installation function interface cd  $dirread  -n1 -t $ hinttime -p  "Is install https? Pls type\ "y/n\"; Please enter y/n to choose whether to install https :  answercase  $answer  iny|y) echo -e  "\ Ninstall https, install HTTPS "sslinstallapacheinstallcd  $apachedir/libcp  $apachedir/ssl/lib/libssl.so.1.0.0 libssl.so.1.0.0cp  $apachedir/ssl/lib/libcrypto.so.1.0.0 libcrypto.so.1.0.0;; N|n) echo -e  "\ninstall http, install http" apacheinstall nhttps;; "") echo -e  "\nenter is empty,will install https, enter as empty default install HTTPS" sslinstallapacheinstallcd  $apachedir/libcp  $apachedir/SSL/LIB/LIBSSL.SO.1.0.0 LIBSSL.SO.1.0.0CP   $apachedir/ssl/lib/libcrypto.so.1.0.0 libcrypto.so.1.0.0;; *) echo -e  "\nonly can type y/y/n/n, can only enter single character y/n/y/n";; Esacexit 0


Linux Automatic installation Script

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.