Write the installation configuration httpd service domain-based virtual host script
Requirements:
1, automatic installation, basic configuration
2, through the prompt input domain name, website root directory, and so on to complete the virtual host add work
#!/bin/bash
Service httpd Stop &>/dev/null
conf= "/usr/local/apache/conf/httpd.conf"
vhostconf= "/usr/local/apache/conf/extra/httpd-vhosts.conf"
Bin= "/usr/local/apache/bin/apachectl"
Rootdir= "/www"
Mkdir-p $rootdir
grep "Vhost" $conf | grep "#" &>/dev/null
If [$?-eq 0]; Then
vhost=$ (grep "vhost" $conf | sed "s/#//")
Sed-i '/vhost/d ' $conf &>/dev/null
echo "$vhost" >> $conf
echo "Namevirtualhost *:80" > $vhostconf
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/
echo "<directory $rootdir >
Order Allow,deny
Allow from all
</Directory> ">> $vhostconf
Fi
While True
Todo
Read-p "hostname of FDQN:" FDQN
Read-p "Directory of website:" SiteDir
Mkdir-p $rootdir/$sitedir/html
Mkdir-p $rootdir/$sitedir/logs
domain=$ (echo $fdqn | awk-f. ' {print $. ') $} ')
echo "<virtualhost *:80>
ServerAdmin admin@ $domain
DocumentRoot $rootdir/$sitedir/html
ServerName $FDQN
ErrorLog $rootdir/$sitedir/logs/error_log
Customlog $rootdir/$sitedir/logs/access_log Common
</VirtualHost> ">> $vhostconf
Read-p "continue to do"? (yes/no) "yn
if [$yn = no];then
$bin Start &>/dev/null
Exit 0
Fi
Done
This article is from the "Soldier" blog, please be sure to keep this source http://ganbing.blog.51cto.com/7002794/1241208