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.

Clean subdomain removal?

Discussion in 'General Discussion' started by jameshurrell, Feb 17, 2011.

  1. jameshurrell

    jameshurrell Member

    Joined:
    Feb 17, 2011
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    1
    A client had two subdomains configured in cPanel (UK and USA). They redirected to public_html/folder/uk and public_html/folder/usa.

    This worked fine, however, the client wanted to clean it up and place the UK and USA folders directly in public_html. Rather than edit the subdomains, he deleted them. This seemed to work OK (they are not listed in cPanel nor in WHM), but he cannot now re-add the subdomains. Instead there is an error:

    Googling this error brings up lots of people with similar issues. I checked the httpd.conf file and the subdomains are still listed there too under virtual hosts - I guess that cPanel has left a trail of data somewhere which is getting pulled into various config files.

    Does anyone have any idea what I need to "clean" to get rid of these domains so that they can be recreated again?

    Many thanks.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello,

    You would want to check the following locations:

    /var/cpanel/userdata/username/main
    /var/cpanel/userdata/username/sub.maindomain.com
    /var/cpanel/users/username
    /var/named/maindomain.com.db

    Any of the above if it has traces of the subdomain will cause the subdomain to continue to be considered existing on the system. Simply make a copy of the file you are editing and then remove the subdomain. For the /var/cpanel/userdata/username/sub.maindomain.com file, simply move the file out of the way. For the /var/named/maindomain.com.db file, you could edit it in WHM > Edit a DNS zone if the subdomain is still there rather than edit that file directly.

    If you did find the subdomain listed in any of the /var/cpanel/userdata/username files, you would need to run the following commands after removing it in the main file there and moving the sub.maindomain.com file there:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110217
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    You would also likely want to run this script after that or possibly after editing /var/cpanel/users/username file:

    Code:
    /scripts/updateuserdomains
    If you directly edited the /var/named/maindomain.com.db file rather than editing it in WHM > Edit a DNS Zone, you'd need to run this command:

    Code:
    rndc reload
    In all of the above, username is the cPanel username, maindomain.com is the main domain name, and sub.maindomain.com is the subdomain name.

    Thanks.
     
  3. jameshurrell

    jameshurrell Member

    Joined:
    Feb 17, 2011
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    1
    EDit: double post - see below.
     
    #3 jameshurrell, Feb 18, 2011
    Last edited: Feb 18, 2011
  4. jameshurrell

    jameshurrell Member

    Joined:
    Feb 17, 2011
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    1
    Thank you Tristan.

    The only place where any of the subdomains were mentioned was in:

    /var/cpanel/users/username

    I copied the file and removed two lines:

    XDNS1=uk.hurrell-it.co.uk
    XDNS2=usa.hurrell-it.co.uk

    I then ran:

    /scripts/updateuserdomains

    I also ran:

    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak18022011
    /scripts/rebuildhttpdconf

    And then restarted Apache. This removed the Vitual Hosts for the subdomains from httpd.conf.

    However, I still cannot re-add the subdomains but I have a different error:

    and there are other problems with the account within cPanel now:

    1) in the "Error Log" there is simply "nolog.html" listed.
    2) The "Advanced DNS ZOne Editor" lists:

    Error
    You do not have permission to read the zone for : hurrell-it.co.uk
    click to close
    No Zone Records Found

    Which is very odd...

    I'm tempted to delete the account through WHM and recreate it as there seems to be quite a bit of mess going on...

    Thanks for any advice.
     
  5. jameshurrell

    jameshurrell Member

    Joined:
    Feb 17, 2011
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    1
    SOmething very odd occurred in this account, so i deleted it and recreated it. Hey presto, all back working. I will remember to avoid creating subdomains through cPanel in the future.
     
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,482
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Creating subdomains via cPanel should not be a problem. The issue here is not uncommon though, IMHO.
    The user creates something one way, and then decides to kill it by simply deleting what he sees in front of him without realizing that the proper way is to remove what ever it is the same way they installed it originally.

    That's not a system issue, thats an end user mistake.

    I see this often with Fantastico users.
     
  7. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Deleting an account & recreating the same is probably not a good idea, you had to contact your DC they would able to manually remove it from httpd.conf file.
     
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Please note that you cannot manually remove a domain in httpd.conf file directly. It must be removed in the /var/cpanel/userdata/username files instead with the steps I noted earlier. If you manually remove a domain in httpd.conf file, it will end up back in that file when /scripts/rebuildhttpdconf is called, which happens on EasyApache update.
     
  9. jameshurrell

    jameshurrell Member

    Joined:
    Feb 17, 2011
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    1
    Creating domains via cPanel works fine, however, deleting them via cPanel does not. Yes, they were removed from the "subdomains" list, but try recreating them again and you won't be able to. cPanel didn't remove the references it should have done when the "Delete subdomain" button was pressed.

    In this instance, this is not an end-user error.
     
    David Colter likes this.
Loading...

Share This Page