Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

 
discard

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.