Create subdomain from command line

I need to create some subdomains for a domain but I can’t use cpanel to do that. The server that I’m working on just doesn’t have it so don’t suggest anything related to cpanel as I’ve seen on most forums.

Can anyone help me with that? I have root access, anything I want. The O.S. is a CentOS 5.5.


Use a seperate file for each vhost and keep them in the same directory. See the documentation for the Include directive (which provides an example of doing exactly that).

How you generate the file is up to you – you might use a template and sed, or just generate the config directly by echo >>$yournewvhost is up to you. Note that the vhost file can itself have Includes – so if you’ve got different groups of sites where you want to enable different groups of functionality, then you don’t need to explicitly state it in each vhost.

Source : Link , Question Author : zozo , Answer Author : symcbean

Leave a Comment