shell脚本之Apache的配置

conf="/usr/local/apache/conf/httpd.conf"

vhost_conf="/usr/local/apache/conf/extra/httpd-vhost.conf"

grep vhost $conf | grep "#" &> /dev/null

if [ $? -eq 0 ];then

vhost=`grep vhost $conf | sed ‘s/#//‘`

sed -i ‘/vhost/d‘ $conf 

echo $vhost >> $conf

echo "

NameVirtualHost *:80

<Directory /var/www>

order allow,deny

allow from all

</Directory>

" > $vhost_conf

fi


while true

do

read -p "please input fqdn of hostname:"  host

read -p "Are you sure?(yes/no)" yn

if [ $yn != yes ];then

continue

fi

mkdir /var/www/$host

echo "

<VirtualHost *:80>

    DocumentRoot "/var/www/$host"

    ServerName  $host

</VirtualHost>


" >> $vhost_conf

read -p "Continue to do?(yes/no)" yn

if [ $yn != yes ];then

break

fi

done

/usr/local/apache/bin/apachectl restart


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。