views:

161

answers:

2

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?

+1  A: 

awk:

{
    fname = $0".conf"
    system("echo found "$0"!")
    print "<VirtualHost blah>" > fname
    print "  ServerName " $0 >> fname
    print "</VirtualHost>" >> fname
}
Ignacio Vazquez-Abrams
Aye, if your problem statement starts off "Read a text file line-by-line..." then you should always consider `awk`.
caf
don't have to use `>>`. Just `>` will do
ghostdog74
+2  A: 

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).

MarkR