shell脚本1例 自动安装httpd

#!/bin/bash

read -n 1 -p "是否已将httpd-2.2.17源码包放到root目录下,确认按Y" p # -n 1指定只能读入一个字符

test "$p" = "y" -o "$p" = "Y"

if [ $? -eq 0 ]

then

    rpm -qa | grep httpd

    rpm -e httpd --nodeps

    cd /root

    tar zxf httpd-2.2.17.tar.gz -C /usr/src/

    cd /usr/src/httpd-2.2.17/

    ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

    make && make install

    ln -s /usr/local/httpd/bin/* /usr/local/bin

 

    cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

    sed -i '1a #chkconfig: 35 85 21 ' /etc/init.d/httpd

    sed -i '2a#descriotion:This is httpd ' /etc/init.d/httpd

    sed -i '97cServerName www.benet.com ' /usr/local/httpd/conf/httpd.conf

    chkconfig --add httpd

    chkconfig --list httpd

    service httpd start

    netstat -anpt |grep httpd

 

    echo " httpd 安装完成 "

 

 

else

    exit 1

fi

原文地址:https://www.cnblogs.com/gdlinux/p/7059614.html