I'd recommend creating a subdirectory in the apache conf
directory. Something like conf/user-domains
. Each file in that directory would be named like the user's domain, such as userdomain.com
, and would contain the apache directives for that subdomain. Something like (off the top of my head):
<VirtualHost *:80>
ServerName userdomain.com
DocumentRoot "/path/to/userdomain.com/htmldocs/"
</VirtualHost>
Assuming you have some web-interface for the user to create those domains, it would store a file with his settings in some known location, such as $webtmp/userrequests/request-XXXYYZ
. You'd then have a cron-job that would scan that location for new requests, and create matching files in conf/user-domains
.
Oh, and do me a favor, and don't just copy input from the user into the config file - that's a great way to get your server hijacked. Check it first, and untaint it if it's legal. (I'd further recommend you give write-only access to conf/user-domains
to a user fakedaemonuser
, and run the cron-job as that user.)
EDIT: Forgot to tell you, you'll need to add a directive in apache's main config file (http.conf
usually):
Include conf/user-domains/*.conf
Of course, that's assuming all the files you're creating in conf/user-domain/
end in .conf
.