Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-25-2006, 07:46 AM   #1
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Rep: Reputation: 15
add subdomain


I have a hosting account on Centos with cPanel.

I would like to offer free subdomains to my customer.

I can add a subdomain in cpanel, and it works fine.

The questions is, How can I make a script that would do that automaticly.

All I need is a script that would add it thru shell. I would do the rest.

Old 04-26-2006, 05:34 AM   #2
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
Might not be your solution but I offer to clients asking for it automatic subdomains. All it takes is a wildcard entry in their dns record and a very simple rewrite rule in their virtual host entry in apache. Then, the simple creation of a directory creates the subdomain.

Here is an example for domain

DNS zone file contains:
$ttl 86400    IN      SOA (
                        86400 )
                IN      NS
                IN      NS
                IN      MX      10
                IN      MX      50
                IN      A       x.x.x.x
www             IN      A       x.x.x.x
mail            IN      A       y.y.y.y
smtp            IN      A       z.z.z.z
*               IN      A       x.x.x.x
The virtual host entry looks like
<VirtualHost *:80>
    DocumentRoot /home/[blabla.comUserHome]/www
    ServerAlias *
    CustomLog /var/log/apache/blabla-access_log combined
    RewriteEngine on
    RewriteCond   %{HTTP_HOST}                 ^(^.+)\.blabla\.com$
    RewriteRule (.*)                    /home/[blabla.comUserHome]/%1/$1
Once this is in place, the user just needs to create a directory in his home dir. It can then be accessed through http://<dirname>


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Subdomain->IP? johndmann Linux - Networking 5 04-03-2006 05:09 AM
Add a subdomain without restarting? newlinuxnewbie Linux - General 3 10-31-2005 05:50 PM
subdomain points a different NS ceynet Linux - Networking 0 08-21-2003 06:48 AM
Subdomain help DoobyWho Linux - General 3 04-14-2003 07:51 PM
subdomain deepak Linux - Networking 2 03-01-2001 10:50 PM

All times are GMT -5. The time now is 10:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration