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 want to add a web site to a Centos VPS programmatically, I found many references to IIS, but nothing for Linux.

I have a site that lets the users create a customized web site. What I want is give the users the option to use their own domain.

So, when the user add his/her own domain (and point his/her domain to my DNS server) add this domain as an add-on domain to my server and also add a virtual host to apache....

any help will be appreciated...

Regards Alex

share|improve this question

Something like cPanel or ISPconfig ?

share|improve this answer
I need this to be programmatically, is there a CPanel API? – Alejandro Angelico Jul 25 '12 at 17:05

You can install virtualmin and use their API via REST URL or run script remotely. It does mailboxes too.

share|improve this answer

Yes, this is simple. I've previously run a webfarm (using 1.3.27) with around 1000 vhosts configured on each server exactly like this - startup took a couple of seconds longer but otherwise there was little difference from a single vhost. Just specify a directory to contain the definitions for the vhosts (one per file) and set up a directory tree for each website. The machine I'm typing this at came with Apache 2.2 pre-configured to handle just such a case; in the httpd.conf there's a line:

Include conf/vhosts.d/*.conf

And the create a file, say containing:

 DocumentRoot /var/vhosts/
 CustomLog /var/vhosts/ common
 ErrorLog /var/vhosts/

You might want to create a user at the same time and point their home directory to the base locattion (/var/vhosts/ I'd recommend disabling all cgi / shtml / php /symlinks etc unless you know how to configure these securely. Preferably allow override none too.

An alternative approach is to use a wildcard vhost with all requests routed to your front controller which would then invoke specific bits of functionality - but this requires rather a lot of development effort.

share|improve this answer
Thanks @symcbean, this is what I want. but is it possible to add the domain to my dns? – Alejandro Angelico Jul 25 '12 at 17:06
Yes - but you don't say what DNS server it is (I used bid and it was much the same process with an SOA record. – symcbean Jul 25 '12 at 21:45
Sorry, I'm using Bind This is returned by # named -v BIND 9.3.6-P1-RedHat-9.3.6-16.P1.el5_7.1 – Alejandro Angelico Jul 26 '12 at 17:04

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.