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'm creating a system where users have their own website on my server with a custom domain, upon an input they desire, e.g.


On one condition, the main domain is domain.org, but domain.org, domain.biz points to the server, but nginx uses the domain.org, how can I let it use domain.biz at the same time?

So if I want a custom script that allows it via command line (that can be run via PHP) that creates a directory in the sites-available and a conf file in the sites-enabled directory so that I can have customised sites in the two directories so when accessing to the custom domain the user entered.

Overall it should:

  1. Create a "virtual host" directory in sites-available and add a conf file in the sites-enabled.
  2. Restart nginx (can a site be added without a restart being required?).

I saw this script, it does what I want, but I need this to take effect on domain.biz, not domain.org since when I enter ./create_site_simple.sh test.domain.biz, it works, but it only works for domain.org/test_domain_biz not test.domain.biz which isn't what I need.

Also I'd like to be able to delete virtualhosts under the command line (via PHP of course).

share|improve this question
What do you mean when you said ./create_site_simple.sh test.domain.biz doesn't work. All are simple shell commands, you can easily custom if you have background about shell scripts. –  quanta Sep 27 '11 at 14:05
Clarified the sentence. –  Burning the Codeigniter Sep 27 '11 at 14:26
Did you point the domain test.domain.biz to your IP address? –  quanta Sep 27 '11 at 14:50
domain.biz already points to the server with a wildcard subdomain *.domain.biz. –  Burning the Codeigniter Sep 29 '11 at 15:15
What happens when you access test.domain.biz? Did you take a look at error log? –  quanta Sep 29 '11 at 16:25
show 2 more comments

Your Answer


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

Browse other questions tagged or ask your own question.