Backups

cPanel Sites Show the Default Page: Restore Missing VirtualHosts in httpd.conf

Missing VirtualHost directives in your Apache configuration? Learn how to restore them in cPanel by rebuilding httpd.conf.

Short answer: cPanel builds Apache’s httpd.conf from the account data in /var/cpanel/userdata. If the VirtualHost blocks are missing and sites show the default cPanel page, rebuild the file with /scripts/rebuildhttpdconf, test it with apachectl configtest, and restart Apache with /scripts/restartsrv_httpd. On current cPanel servers the file is at /etc/apache2/conf/httpd.conf.

Symptoms

  • Every site on the server shows the default cPanel or Apache page.
  • Some sites work, others show the default page or another site’s content.
  • The VirtualHost blocks are missing from httpd.conf, or the file is much smaller than usual.

Why it happens

cPanel never expects httpd.conf to be edited by hand. It regenerates the file from templates and from each account’s settings in /var/cpanel/userdata/USERNAME/. VirtualHosts can disappear when:

  • Someone edited httpd.conf directly and a rebuild replaced it.
  • A rebuild ran while the disk was full, leaving a truncated file.
  • The userdata files for accounts are missing or damaged, for example after a partial restore.
  • A custom template or include contains an error.

Step 1: check the current file

ls -l /etc/apache2/conf/httpd.conf
grep -c "<VirtualHost" /etc/apache2/conf/httpd.conf     # number of VirtualHost blocks
df -h /etc /var                                         # make sure the disk is not full

Older guides use /usr/local/apache/conf/httpd.conf. That path belongs to EasyApache 3; current servers use EasyApache 4 and the path above.

Step 2: back up and rebuild

cp -a /etc/apache2/conf/httpd.conf /root/httpd.conf.$(date +%F-%H%M)

/scripts/rebuildhttpdconf
grep -c "<VirtualHost" /etc/apache2/conf/httpd.conf

The count should now be roughly two per domain (one for HTTP and one for HTTPS).

Step 3: test and restart Apache

apachectl configtest        # should print "Syntax OK"
/scripts/restartsrv_httpd

Open a few sites and check they show their own content.

Check how Apache sees one domain

Apache can list every VirtualHost it loaded, with the file and line where each one is defined. This shows quickly whether a domain is missing or attached to the wrong IP address:

apachectl -S 2>/dev/null | grep -i example.com

# Ask the server for the site directly, bypassing DNS
curl -sI -H "Host: example.com" http://SERVER_IP/ | head -n 5

If apachectl -S does not list the domain, its VirtualHost is missing. If it is listed under a different IP address than the one DNS points to, change the account’s IP in WHM or fix the DNS record.

If the rebuild does not bring the sites back

The rebuild only works if the account data is intact. Check that each affected account has its userdata files:

ls /var/cpanel/userdata/USERNAME/
# expect: main, the domain file(s) and their _SSL versions

If files are missing, refresh cPanel’s data and rebuild again:

/scripts/updateuserdatacache
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd

If the account data was lost, restore it from a backup: the userdata is part of every cPanel account backup. See our cPanel backup and restore guide.

Step 4: repair cPanel if needed

/scripts/upcp --force

A forced update reinstalls cPanel’s templates and scripts. Run it if the rebuild script itself reports errors.

Keep custom Apache settings safe

  • Never edit httpd.conf directly. cPanel overwrites it.
  • For server-wide settings, use WHM > Service Configuration > Apache Configuration > Include Editor.
  • For one domain, put custom directives in an include file under /etc/apache2/conf.d/userdata/, as cPanel documents, then rebuild.
  • Keep enough free disk space, so rebuilds never write a partial file.

Troubleshooting

Problem Likely cause Fix
apachectl configtest fails An error in an include or custom template Read the line it names, fix or remove the include, and rebuild.
Only one site is missing That account’s userdata is damaged Run /scripts/updateuserdatacache, or restore the account from backup.
Sites show the wrong site Two accounts claim the same IP and domain, or DNS points to another IP Check the account IPs in WHM and the DNS records.

Need help with this?

Sites down after a configuration change? Our team can repair Apache and cPanel quickly.

See server management plansContact @CustomerPanel

Frequently asked questions

Where is httpd.conf on a cPanel server?

On current servers with EasyApache 4, at /etc/apache2/conf/httpd.conf.

How do I rebuild Apache’s configuration on cPanel?

Run /scripts/rebuildhttpdconf, then test with apachectl configtest and restart with /scripts/restartsrv_httpd.

Can I edit httpd.conf by hand?

No. cPanel regenerates it. Use the Include Editor or userdata include files instead.

Why do my sites show the default cPanel page?

Apache has no VirtualHost for the domain, or the domain points to a different IP address than its account uses.

What if the rebuild does not help?

Check the account data in /var/cpanel/userdata, refresh it with /scripts/updateuserdatacache, or restore it from backup.


Sources