LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

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

Rep: Reputation: 15
add subdomain


Hello,

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.

Thanx.
 
Old 04-26-2006, 04:34 AM   #2
zeitounator
Member
 
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 blabla.com.

DNS zone file contains:
Code:
$ttl 86400
blabla.com.    IN      SOA     somenameserver.com. contact.blabla.com. (
                        2006042601
                        21600
                        3600
                        604800
                        86400 )
                IN      NS      somenameserver.com.
                IN      NS      somebackupnameserver.com
                IN      MX      10 mail.blabla.com.
                IN      MX      50 somebackupMX.com
                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
Code:
<VirtualHost *:80>
    ServerAdmin webmaster@blabla.com
    DocumentRoot /home/[blabla.comUserHome]/www
    ServerName blabla.com
    ServerAlias www.blabla.com
    ServerAlias *.blabla.com
    CustomLog /var/log/apache/blabla-access_log combined
    RewriteEngine on
    RewriteCond   %{HTTP_HOST}                 ^(^.+)\.blabla\.com$
    RewriteRule (.*)                    /home/[blabla.comUserHome]/%1/$1
</VirtualHost>
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>.blabla.com
 
  


Reply


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 04:09 AM
Add a subdomain without restarting? newlinuxnewbie Linux - General 3 10-31-2005 04:50 PM
subdomain points a different NS ceynet Linux - Networking 0 08-21-2003 05:48 AM
Subdomain help DoobyWho Linux - General 3 04-14-2003 06:51 PM
subdomain deepak Linux - Networking 2 03-01-2001 09:50 PM


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

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