添加apache虚拟主机脚本
时间:2009-04-29 来源:forward51
#!/bin/bash
#Add a vhost
#vhost configfile is vhost.conf echo ""
echo "<Directory \"Directorypwd\">" >> ./vhost.temp
echo "Options FollowSymLinks" >> ./vhost.temp
echo "AllowOverride All" >> ./vhost.temp
echo "Order allow,deny" >> ./vhost.temp
echo "Allow from all" >> ./vhost.temp
echo "AddDefaultCharset GBK" >> ./vhost.temp
echo "Options +Includes" >> ./vhost.temp
echo "</Directory>" >> ./vhost.temp
echo "" >> ./vhost.temp
echo "" >> ./vhost.temp
echo "<VirtualHost *:80>" >> ./vhost.temp
echo "ServerName " >> ./vhost.temp
echo "DocumentRoot " >> ./vhost.temp
echo "DirectoryIndx index.shtml index.html index.php" >> ./vhost.temp
echo "</VirtualHost>" >> ./vhost.temp
echo ""
echo "Please input Directory ( example \"/var/www/html/\" ):"
read Directory echo ""
echo "Please input ServerName ( example "www.example.com" ) :"
read ServerName sed -e /Directory/{s:Directorypwd:${Directory}:} -e /ServerName/{s/$/$ServerName/} -e /DocumentRoot/{s:$:${Directory}:} vhost.temp >> vhost.conf rm -f ./vhost.temp echo ""
echo '###################'
echo '# #'
echo '# "Add vhost OK!" #'
echo '# #'
echo '###################'
echo ""
tail -n 16 vhost.conf
#Add a vhost
#vhost configfile is vhost.conf echo ""
echo "<Directory \"Directorypwd\">" >> ./vhost.temp
echo "Options FollowSymLinks" >> ./vhost.temp
echo "AllowOverride All" >> ./vhost.temp
echo "Order allow,deny" >> ./vhost.temp
echo "Allow from all" >> ./vhost.temp
echo "AddDefaultCharset GBK" >> ./vhost.temp
echo "Options +Includes" >> ./vhost.temp
echo "</Directory>" >> ./vhost.temp
echo "" >> ./vhost.temp
echo "" >> ./vhost.temp
echo "<VirtualHost *:80>" >> ./vhost.temp
echo "ServerName " >> ./vhost.temp
echo "DocumentRoot " >> ./vhost.temp
echo "DirectoryIndx index.shtml index.html index.php" >> ./vhost.temp
echo "</VirtualHost>" >> ./vhost.temp
echo ""
echo "Please input Directory ( example \"/var/www/html/\" ):"
read Directory echo ""
echo "Please input ServerName ( example "www.example.com" ) :"
read ServerName sed -e /Directory/{s:Directorypwd:${Directory}:} -e /ServerName/{s/$/$ServerName/} -e /DocumentRoot/{s:$:${Directory}:} vhost.temp >> vhost.conf rm -f ./vhost.temp echo ""
echo '###################'
echo '# #'
echo '# "Add vhost OK!" #'
echo '# #'
echo '###################'
echo ""
tail -n 16 vhost.conf
相关阅读 更多 +