I tried to remove an old subdomain from WHM/cPanel today through both List Subdomains in WHM and in Domains in cPanel and kept getting the following error.
Well, the down and dirty on this one was just to edit the DNS Zone for the primary domain by deleting all references to domainodelete.com. Remember to Restart the DNS server to make sure changes are set.
Below shows where to restart the DNS in WHM. If you only have cPanel access, submit a ticket to your hosting provider to request a DNS Server reset.
However, I wanted it completely cleaned up on the server. So I was off to remove the subdomains manually via SSH.
I need to note that you will need root access to the server, for me this occurred on my VPS.
I SSHed into the server using Putty for my client in Windows. Once logged in I bumped myself up to root authority.
Then I changed to the /etc/named directory
I then opened named.conf using my favorite editor vi to make sure none of the subdomains were listed and they were not.
I then checked the /var/named directory for any db files, again there were none.
Next I opened /etc/localdomains in vi
In here I found the subdomains I was looking for and I deleted the ones I no longer wanted.
I also checked the remote domain file for unwanted domains, of which I found none.
Finally the last place I looked was /etc/userdomains. I found the subdomains and deleted them.
After doing all of that, I went ahead and restarted Apache through WHM. Upon checking I still could not remove the domains. I kept getting the following error: Error: You do not have control of the domain domaintodelete.com
I then took the looked at /var/cpanel/users/cpanel-username and deleted the dmaintodelete.com DNS entries and XDNS entries. That took care of the domains in cPanel but not WHM.
Finally, I opened Apache’s httpd.conf file and deleted the virtual host for domaintodelete.com.
Be VERY CAREFUL with this, there are a number of lines for each Virtual Host and it is very easy to not delete enough or delete too much. Identify the beginning and end of the section beofre you begin to delete anything.
From there, I once again restarted Apache and I also restarted the DNS for good measure. Finally I refreshed WHM. Still no go, they were still there showing as parked.
Well during my time deleting Virtual Hosts, I noticed a *.conf reference at
Upon going the directory listed, I found an empty subdirectory for the subdomaintodelete.com and subdomaintodelete.maindomain.com. I deleted them both.
Restarted Apache and DNS and off to WHM, they were still there. The next step was to find all files on the vps with domaintodelete in the file name somewhere.
So here are all the directories where a file with that name showed up:
I went and deleted any files and folders associated with doaintodelete.com from each of those directories listed above manually. I am not sure if it was absolutely necessary, I just did it anyways.
This little project opened my eyes because as I was poking around, it was amaizing how much old information is still floating around in the files on the server, from old domains to old user account names buried throughout.
AS ALWAYS – USE THE ITEMS AT YOU OWN RISK and ALWAYS MAKE BACKUPS BEFORE MAKING CHANGES.