shell script to add list of domains to apache vhosts
I have a list of ~900 domains that I need to set up on a linux/apache server.
It would be absolutely brutal to create all of the users/groups/vhosts by hand. Does anybody know of a resource that I could use to automate this?
I guess the script should do these actions: Read text file line by line开发者_开发技巧 in to array For each item in array: Useradd Create vhost directory and set it as home for said user Create vhost file in /sites-available/
Does anybody have experience with this?
You should really use the Dynamic virtual hosts
That way you don't need to explicitly configure any of them. Creating a directory is sufficient for Apache to start serving that virtual host (provided the DNS entries point to it).
awk:
{
fname = $0".conf"
system("echo found "$0"!")
print "<VirtualHost blah>" > fname
print " ServerName " $0 >> fname
print "</VirtualHost>" >> fname
}
精彩评论