3

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 example.com, 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 custom_subdomain.example.com 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.

dgh
  • 478
  • 1
  • 3
  • 11

1 Answers1

3

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.

Lucas Kauffman
  • 16,880
  • 9
  • 58
  • 93
  • Thanks. I'll look into using a ready-made server control panel. – dgh 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. – dgh Aug 06 '12 at 23:23