Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to create a website on my server, which runs Apache2, to allow a user to fill in a form containing a desired subdomain name to be created on the server. For example, a user could go to the site on the server at, fill out the form with a desired subdomain 'custom_subdomain', and on the server-side, a script will create the appropriate Vhost file in apache2/sites-available, a2ensite it, and restart the apache2 server.

This will effectively create on the server. What I'm unsure of is how to create a server-side script which can actually perform these actions since they require root level access (both to create a new vhost file and restart the server). I DO NOT want apache2 running as ROOT and lets assume I properly escape the user's desired subdomain entry so that it does not contain malicious code. Also my website will have some form of login security. How can I go about writing such a script? My back-end will be written in (Django) Python or Node.js.

The reason I wish to create this interface is that I have some collaborators who should have the ability to create subdomains easily, but who should not have the ability to tinker with any apache configuration manually.

share|improve this question
up vote 3 down vote accepted

How about not re-inventing the wheel and just use a control panel like ISPConfig. You can disable unwanted features and only allow the subdomaining.

share|improve this answer
Thanks. I'll look into using a ready-made server control panel. – dghubble Jul 29 '12 at 21:03
For other readers, I also found munin, webmin/virtualmin/cloudmin, and cpanel to be worth looking into. I went with webmin. – dghubble Aug 6 '12 at 23:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.