码迷,mamicode.com
首页 > Web开发 > 详细

shell脚本之Apache的配置

时间:2014-11-27 18:56:06      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:continue

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


shell脚本之Apache的配置

标签:continue

原文地址:http://mengwumian.blog.51cto.com/9562947/1583121

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!