Most of us might encountered this problem while adding a sub-domain or add-on domain in the server. You would want to check the following locations:
Probably you may prefer the commands to do this for you:
]# grep domain.com /var/cpanel/users/*
]# grep -R domain.com /var/cpanel/userdata/*
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 sub-domain is still there rather than edit that file directly. Even if you are editing the /var/named/maindomain.com.db (in the case of subdomain) or /var/named/add-on-domain.com.db (in the case of Add-on Domain) via SSH, you need to run the command below to refresh the Zone files in your server.
]# rndc reload
Once you are done with the removing the traces of the sub-domain or add-on domain from your server by following the steps mentioned above, you may need to run the following commands to make sure that your changes are saved.
You need to rebuild your Apache configuration.
]# cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_bak
]# /etc/init.d/httpd restart
You need to update your user domains list file “/etc/userdomains”.
Now you should not face any problems with adding the sub-domain or add-on domains from your cPanel.
I wish you all a very Good Life Friends!!! Have Fun!!!!! 🙂 😉