The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to create subdomain in linux by command

Discussion in 'General Discussion' started by Behrooz_Ice, Jul 30, 2005.

  1. Behrooz_Ice

    Behrooz_Ice Member

    Joined:
    Apr 3, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    IRan
    hello all
    i have a question. i want to create a subdomain for a special domain in linux server by terminal command. i dont want use gui hosting panel for that. which command should be use in terminal?
    i have do edit httpd.conf by vi command and add subdomain in that, but that subdomain didn't work and i cant load my new subdomain by browser. here is my httpd.conf:

    #<VirtualHost 192.168.1.21>
    #DocumentRoot /home/chiron/public_html/mydomain
    #ServerName mydomain.com
    #ServerAlias www.mydomain.com
    #</VirtualHost>

    #<VirtualHost 192.168.1.21>
    #DocumentRoot /home/chiron/public_html/mydomain/bbtest
    #ServerName bbtest.mydomain.com
    #ServerAlias bbtest.mydomain.com
    #</VirtualHost>

    what am i do for solve this problem? do i should reset httpd.conf or apache service for active this subdomain? anyone have better way to create subdomain by command?
    regards
     
  2. brentp

    brentp Well-Known Member

    Joined:
    Mar 11, 2004
    Messages:
    324
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Ayr, North Queensland, Australia
    no such command to do so. You would have to edit the dns zone, reload rndc, edit httpd.conf and some other stuff.

    Regards,
    Brent
     
  3. Behrooz_Ice

    Behrooz_Ice Member

    Joined:
    Apr 3, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    IRan
    first i do edit httpd.conf , for next step i should edit zone file and then reload rndc ?
    please tell me step by step. regards
     
  4. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    If you don't know how to do that yourself, you should probably just use the inbuilt functions of cPanel to do it. Otherwise, you'll need to teach yourself how apache and bind work. You can get the bind documentation from:
    http://www.isc.org/sw/bind

    Bascially, you're going to have to edit the zone file and add an A record for the subdomain and then increase the serial number and reload bind to propagate the change.
     
  5. Behrooz_Ice

    Behrooz_Ice Member

    Joined:
    Apr 3, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    IRan
    thank you
    my question is what's the name of zone file and where is locate?
    i know /var/named is locate of zone files, is it true?
    another question is apache service shuold be restart for active new subdomain after that create? is it necessary or not?
    regards
     
  6. sheenz_km

    sheenz_km Registered

    Joined:
    Jul 18, 2005
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    add subdomain

    You need to edit /var/named/maindomain.com.db file. You will have to add entries for the subdomain in this file.
    Apache needs to restarted if you have made any changes to the httpd.conf file.

    There is no command to add a subdomain. To make things simpler you can add the subdomain using cpanel.
     
Loading...

Share This Page