shell腳本之Apache的配置

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

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

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

if [ $? -eq 0 ];thenrest

vhost=`grep vhost $conf | sed 's/#//'`input

sed -i '/vhost/d' $conf it

echo $vhost >> $confclass

echo "sed

NameVirtualHost *:80grep

<Directory /var/www>tab

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

相關文章
相關標籤/搜索