HiBlog Hosting and cPanel

How to Host Two Websites on One Hosting Account: Second Domain, Subdomain or Folder

  • Mina SeyfollahiAuthor
  • Last updated
  • 7 minutesReading time
  • 567Views
  • Mina Seyfollahi
  • Last updated:
  • 7 min read
  • 567 views
How to Host Two Websites on One Hosting Account: Second Domain, Subdomain or Folder

Your online shop is up on your hosting and running well; now you want to launch a blog, a company site or a client’s site too. You don’t need to buy separate hosting for each site! Most cPanel and DirectAdmin hosting lets you keep several domains and independent sites on one account, each with its own folder, database and mailboxes.

In this guide you’ll see three ways to host two websites on one account, step by step: a second domain, a subdomain and a separate folder. Then we create a database for each site and cover the points that, if ignored, let one site slow down or infect the other.

Short answer: in cPanel, go to Domains, click Create A New Domain, enter the second domain and untick Share document root so it gets its own folder. Point the second domain’s nameservers to the hosting’s nameservers, install your files or WordPress in the new folder and create a separate database for the second site. In DirectAdmin, the same is done from Domain Setup with the Add New button.

Before you start: how many domains does your hosting allow?

Every hosting plan has a limit on domains. In cPanel you see it in the Statistics column of the home page, next to Addon Domains and Subdomains; for example 2 / ∞ means two domains added and no limit, while 0 / 0 means your plan doesn’t allow a second domain. In that case either use a subdomain or a separate folder, or upgrade the plan.

Addon Domains and Subdomains counts in cPanel's Statistics column

Method 1: a second domain with its own folder (addon domain)

This is the most common method: two sites with two completely separate domains, such as example.com and example2.com, on one hosting account.

  1. Log in to cPanel; if you don’t know its address, see how to log in to cPanel.
  2. In the Domains section, click Domains and then Create A New Domain.
  3. Enter the full second domain, for example example2.com.
  4. Untick Share document root so the second site gets its own folder. cPanel suggests a folder name, which you can change.
  5. Click Submit.

In older versions of cPanel this was done in a separate Addon Domains section; if your hosting still has it, the steps are the same.

The Addon Domains section in older versions of cPanel

Now the second domain has to reach this hosting: in the domain’s panel, set its nameservers to the ones in your hosting welcome email. A nameserver change can take up to 24 hours, sometimes up to 48, to be seen everywhere. Then upload the second site’s files to the new folder or install WordPress on it; in Softaculous, just pick the second domain from the list during installation. We walk through installing WordPress in how to install WordPress in cPanel.

Method 2: a subdomain (blog.example.com)

If the second site is part of the same brand, such as a blog or a shop, a subdomain is the best choice and needs no new domain. In newer cPanel versions you create subdomains from the same Domains page with Create A New Domain; just enter the full address, such as blog.example.com, and untick Share document root. Older versions have a separate Subdomains section. If the domain’s DNS is hosted on the same account, the subdomain works right away.

Method 3: a separate folder under one domain (example.com/shop)

The simplest method is a folder inside public_html, for example a shop folder that opens at example.com/shop. Create the folder in File Manager and put the second site’s files in it; for WordPress, enter the folder name in Softaculous’s In Directory field. This works well for a section of the same site, but two fully independent sites are better off with their own domain or subdomain.

MethodExample addressNeeds another domain?Best for
Second (addon) domainexample2.comYesTwo independent businesses or brands
Subdomainblog.example.comNoA blog, a shop or another version of the same brand
Separate folderexample.com/shopNoA section of the same site

Adding a second domain in DirectAdmin

In DirectAdmin, click Domain Setup in the Account Manager section, choose Add New and enter the second domain. DirectAdmin creates a separate folder for each domain at domains/example2.com/public_html, and that’s where the second site’s files go. Subdomains are created under Subdomain Management. We compare the two control panels in cPanel or DirectAdmin.

A separate database for each site

Each site should have its own database, so a breakage or backup restore on one doesn’t touch the other. If you install WordPress with Softaculous, the database is created automatically. For a manual install:

  1. Click MySQL Databases in cPanel’s Databases section.
  2. Create a new database and a new user, and add the user to the database with ALL PRIVILEGES.
  3. Enter the database name, username and password in the site’s configuration file; in WordPress, wp-config.php.
MySQL Databases in cPanel's Databases section

Key points for running two sites on one hosting account

  • Resources are shared: the plan’s CPU, RAM, disk space and file count are split between all its sites, so one busy site slows the other down too. Watch the usage in cPanel’s Resource Usage and upgrade when the sites grow.
  • So is security: sites on one hosting account run as the same user, and if one is hacked, the attacker can reach the other’s files as well. Keep WordPress, themes and plugins of both sites updated and delete unused plugins. If the two sites belong to two separate businesses, give each its own hosting account.
  • An SSL certificate for each domain: cPanel usually issues a free certificate with AutoSSL for every domain and subdomain once its DNS points to the hosting. If it doesn’t, see how to install SSL in cPanel.
  • Separate email for each domain: each domain can have its own mailboxes, such as info@example2.com.
  • DNS and TTL: if the domain’s DNS is on the hosting, you set its records and their TTL in cPanel’s Zone Editor.
  • Backups of both sites: a full hosting backup covers both sites together, but to restore just one, also keep separate backups of its files and database.
Managing two websites on one hosting account

Frequently asked questions

Can I install two WordPress sites on one hosting account?

Yes. Install each WordPress in its own domain or subdomain folder with its own database; Softaculous does this for each domain in a few clicks.

Can two sites share one database?

Technically yes, if each site’s tables have a different prefix. But it makes backups and restores harder and lets damage to one reach the other; create a separate database for each site.

Can I manage several sites from one WordPress install?

Yes, WordPress Multisite runs several sites from one install and one dashboard. It suits sites that share plugins and users; for two independent sites, two separate installs are simpler.

What’s the difference between a wildcard and a multi-domain SSL certificate?

A wildcard certificate covers all subdomains of one domain, such as blog.example.com and shop.example.com; a multi-domain certificate puts several different domains, such as example.com and example2.com, in one certificate. On cPanel hosting you usually need neither, because AutoSSL issues a separate certificate for each domain and subdomain.

Multi-site hosting from HiData

If you need room for several sites, take a look at HiData’s professional cPanel hosting: daily, weekly and monthly backups of the whole account with free restores, and free transfer of your current sites without downtime. For busy sites, high-traffic hosting has more resources. If you’re just starting out, read what web hosting is.

Sources

Share Post

hidata.org/en/blog/two-website-one-host/
In Social Media

Add Comment

Related Articles