I was unable to remove a subdomain from my Cpanel giving me the error:

[html]
There was a problem removing the subdomain
[/html]

To fix the issue I carried out the following steps:

1. Backup the following files:

/var/cpanel/userdata/username/main
/var/cpanel/userdata/username/sub.maindomain.com
/var/cpanel/users/username
/var/named/maindomain.com.db
/var/cpanel/userdata/account/sub.domain.com
/var/cpanel/userdata/account/sub.domain.com.cache
/usr/local/apache/conf/httpd.conf

2. Remove all lines containing the subdomain from /var/cpanel/userdata/username/main:

[html]
vim /var/cpanel/userdata/username/main
[/html]

3. Remove the subdomain file completely from /var/cpanel/userdata/username/:

[html]
rm /var/cpanel/userdata/username/sub.maindomain.com
[/html]

4. Remove all lines containing the subdomain from /var/cpanel/users/username:

[html]
vim /var/cpanel/users/username
[/html]

5. Remove all lines containing the subdomain from /var/named/maindomain.com.db:

[html]
vim /var/named/maindomain.com.db
[/html]

6. Remove subdomain files from /var/cpanel/userdata/account/:

[html]
rm /var/cpanel/userdata/account/sub.domain.com
rm /var/cpanel/userdata/account/sub.domain.com.cache
[/html]

7. Now we need to rebuild some files and restart apache:

[html]
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
/scripts/updateuserdomains
[/html]

Now login to your CPanel interface and check the subdomain is removed.

If not try and add the same subdomain again and then remove. This worked for me.

That should be it gone.

*This was taken from http://forums.cpanel.net/f5/clean-subdomain-removal-192441.html. Step 6 was the extra step I needed to take to complete the removal.

Written by Matt Cooper
Hi, I'm Matt Cooper. I started this blog to pretty much act as a brain dump area for things I learn from day to day. You can contact me at: matt@matthewc424.sg-host.com.