Close

March 4, 2011

Setting the Default Website CPANEL Account in WHM

We ran into a situation recently, where a wildcard SSL cert was purchased for a customer. When setting up the cert for the entire server, WHM/CPANEL would not tag the default CPANEL account with the new cert. Apache would serve the SSL, but the Apache conf file was not picking up the domain name.

Tech support had “fixed” the problem, by hand-editing the ‘/usr/local/apache/conf/httpd.conf’ file in the respective “VirtualHost” setting, however it clearly says ” DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.”

Naturally, upon a new subdomain addition, this file was “AUTOMATICALLY GENERATED” and that change was stomped. This caused our default SSL page to be redirected back to the WHM default “/usr/local/apache/htdocs” folder.

We finally stumbled on the solution to solve this issue, once and for all!

Forcing Default CPANEL Account in WHM For Wildcard SSL

A.) First Step: Setup and install all of your accounts/wildcard SSL accounts
WHM.

B.) Second: Take a look at the /usr/local/apache/conf/httpd.conf file.
Find the default virtual hosts for port 80 and 443 and copy them to a notepad/text file.

Should be something like:

<VirtualHost YOURIP:443>
    ServerName *.domain.com
    ServerAlias www.*.domain.com www.dev2.domain.com dev2.domain.com www.domain.com domain.com
    DocumentRoot /home/UserAccountSetupInWHM/public_html
 
...

and

<VirtualHost YOURIP:80>
    ServerName domain.com
    ServerAlias www.dev2.domain.com dev2.domain.com www.domain.com domain.com
    DocumentRoot /home/UserAccountSetupInWHM/public_html
 
..
    Now the Fix!

1.) In WHM goto “Service Config”
2.) Apache Configuriatin
3.) Include Editor
4.) Post VirtualHost Include-> ALL VERSIONS
5.) PASTE the previous Virtualhost definitions into the post file. Change log file locations etc. This will be executed AFTER all of the other apache conf files are processed, so it will override any of the previous settings. This will ensure that these configurations take precedent and WILL NOT be overwritten by WHM.

** BE SURE TO CHECK THAT THE USER IN THE SSL VERSION MATCHES THE USER IN THE 80 and NOT the nobody user****

6.) CAUTION: Remember that these are now hardcoded into the system. If you want to add a new “parked account” or Server Alias to this default site, you will ALSO need to add it to this “Post VirtualHost Include” section.

7.) Hit UPDATE and Restart Apache. Test..Test…and Re-test. If this is going to be a production environment, reboot the server to make sure everything sticks.