首页 > 代码库 > shell脚本之Apache的配置
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
shell脚本之Apache的配置