Home » Create and run a subdomain in wordpress

Create and run a subdomain in wordpress

How to create a Subdomain with wordpress installation through Cpanel

In this tutorial, we have provided a detailed method for creating a subdomain, installing wordpress and database for your subdomain and bringing your subdomain online including ssl. The entire process looks long but can be completed in minutes.

Subdomains can be useful in various situations and several times you must have noticed websites with many subdomains. There are several large blogs that have separate subdomains dedicated to various areas like tech, business, entertainment and politics.  The most obvious reason that businesses use subdomains is branding. For example, a business can use a subdomain for its support channel and another one for a forum.

Forum.website.com, blog.website.com, tech.website.com and support.website.com are all examples of subdomains. The subdomains are just like main domains and except for the common root domain, there is nothing common between them. They can use separate databases and WordPress installations. Since subdomains can be useful in many situations, and especially if you are planning to start a forum or blog along with your main website, it can be very useful.

Creating a subdomain does not require much technical expertise and except for Cpanel access and the right permissions, you will not need anything else to create a subdomain and install WordPress on it. Suppose, you are running a service website and you also plan to start a blog with it for content marketing. You can do it in two ways. You can either run your blog from a subdirectory like website.com/blog or use a subdomain to create a blog like blog.website.com. Since blog.website.com appears better in terms of branding, most businesses go for this option.

How to Create a Subdomain on WHM/Cpanel server

The process of creating a subdomain is nearly same as creating a main domain and installing WordPress. Login to the Cpanel and select domains from there. Enter the domains section. On this page, you will find a list of domains that are already operational in your account.

On the right, you will find create a new domain button. Click on it to create your new subdomain.

Enter the name you have selected for your subdomain like my.example.com into the domain name box. Now, you can select to share the document root with your main domain or create a new directory for your subdomain. Create a new directory and give it the name of your subdomain. If you are creating my.website.com, you can name it my. If it automatically fills the complete subdomain like my.example.com, you can delete the rest and keep only the prefix my for your document root for your subdomain. The path to your subdomain home directory in this case will be /home/main domain/public_html/my. Once you have filled the necessary information, hit submit.

The first stage of subdomain creation is complete. However, a lot of work still remains. You will need to install wordpress on your subdomain and database as well as add ssl before you can start adding content to it.

How to Install WordPress and Mysql Database for Your Subdomain

The best thing is that adding WordPress and the database are not as difficult since you can install them with just a few clicks on your subdomain. In your Cpanel, go to the WP toolkit. On the WP toolkit interface, you will see a list of the WordPress domains that are already active (including main domain and any previously added subdomains. This interface also includes links to updating your themes and plugins installed on the WordPress websites in your cpanel account.

On this panel, you will find various buttons for installing, updating and scanning WordPress for security threats.  Click on the install button to start wordpress installation on your subdomain. There are other methods to install WordPress to and if you are good with terminal commands, you can easily download wordpress latest version and install it from there. However, installing it from the Cpanel is also hassle free and you can install everything you need to run a wordpress website by just a few clicks.

When you click on the install button on the left, it will open a new panel titled Install WordPress. The top section is general in which you can specify the installation path and the basic themes and plugins you want installed with your wordpress installation.

In the Installation path box, under the general section, select https (we will add ssl to our subdomain later). Click in the box to its right and from the dropdown menu select the subdomain we have just created. The last part of the installation path of the directory in which you want to install WordPress. You can name it wordpress or leave it blank if you want it in the main directory from where you are running your subdomain.

Install wordpress subdomain cpanel

Give the website a title (fill in the website title box) and for WordPress plugin/theme set select wordpress essentials from the dropdown menu. If you also want Jetpack preinstalled on your wordpress subdomain, you can select WordPress essentials with Jetpack. Select the website language and for wordpress version, select the latest version in the dropdown menu.

The next section is wordpress administrator, where you will find the username and password for your wordpress subdomain admin panel (wp-login). It automatically generates a random username. You can use the default provided by wordpress since they are secure or select to change the admin name and password if you want to set an admin name that is easier to remember.

The next section is database. You will see that the system automatically fills in the details including database name, table prefix, user name and password. You can use the default provided by the system. In both wordpress admin and database user, copy the username and password and save them in a safe place. Click on show password for each to copy the passwords.

The last section in the wordpress installation is of automatic updates. Here you can go with the default settings or change the settings for automatically updating WordPress to no. The themes and plugins are not updated automatically unless you select to do so from here.

We are done now. Click on Install. The installation process lasts just a few minutes. After that you will receive the installation complete message.

The new wordpress installation will be listed at the top in the list of wordpress websites on the Wp Toolkit interface. You will find the information about wordpress and php version available here on the right like shown in the image below. You will see more sections beside the dashboard including plugin themes and database to manage these features separately. You can also see a link to File Manager on the dashboard from where you can check out your home directory. Visit these sections. To visit your home directory and the mysql database using phpmyadmin, you can find the direct links right here.

Managing DNS for Your Subdomain

Before moving ahead, I should make it clear that you do not have to worry about DNS settings if your DNS provider is the same as your hosting provider. However, if you are using a premium DNS provider, you will need to add DNS records there for your subdomain. Unless you plan to use email and other things with your domain, you will mainly need to add an A record to make the subdomain operational. Your subdomain uses the same IP as the main domain and you will find its DNS records at your host included in your main domain’s DNS zone. If you want to verify, you can go to zone records in the cpanel and click on manage next to your main domain. You will see the newly added A and TXT records there for your subdomain.

If you are using Cloudflare or another premium DNS provider, quickly add an A record in your DNS zone there and point it to your domain IP. Your wordpress subdomain is online and you can visit the login page from:

subdomain.com/wp-login.php

Or you can just click on plugins in the WP toolkit interface and from there click on start managing in wordpress. The link will take you to the wordpress installation and you will be logged in. 

SSL for your subdomain

In some cases, the autossl automatically detects the newly added subdomain and installs an ssl. If it does not, you can run autossl from cpanel manually.

Run auto ssl from cpanel

Go to SSL/TLS Status in Cpanel  and click inside the box in the left of the subdomain for which you want to run autossl. If system has already installed it, you will see a green lock sign to the left of your subdomain. Otherwise, you can select the domains and subdomains that you want to add ssl to and then click on run autossl. It will install ssl on the subdomain. With ssl, the final stage of your subdomain creation is complete and it’s time to check out your new website.

You are all set!

The good thing about installing wordpress in the above detailed manner is that when you login to the wordpress admin panel for the first time, you have everything set and ready. You have to worry about nothing but changing the theme and plugins according to your choice and start editing your wordpress subdomain or adding content. Your database is already operational and you have set every detail right at the first step when you started the wordpress installation process from WP Toolkit in Cpanel.

If you use other methods for installing wordpress, you might need to add the details like website language and then the mysql database at the end. However, we have already completed these steps right at the outset and there is no heavy work remaining for us. You will find the ‘hello world’ post on your subdomain, which you can delete and add your own posts and remove any unnecessary plugins currently installed. WordPress installs a default wordpress theme like Twenty Twenty One when you first install wordpress.

Start new wordpress blog

So, what remains to be done at this stage. Nothing! Now, it’s time to check out our database and home directory.

Remember the login link for your wordpress admin panel is nothing else but your subdomain.com/wp-login.php.

You already have the username and password saved. You can also login to the new database.Go back to the WP Toolkit interface and login to the database through phpMyAdmin from there. Click on database next to your subdomain and then you will find necessary details including database name, table prefix, user name and database server there. Next to the database name, you will also find the link to login to the database through phpMyAdmin.

From the same interface, you can also check out the home directory for your subdomain. Just click on file manager under the dashboard section next to the newly installed subdomain in wp-Toolkit in Cpanel. The WP-Toolkit provided in your cpanel account is the easiest way to install wordpress on any new domain or subdomain. If you want to add and manage several subdomains in your account, then wordpress multisite might make your task easier. However, if you want to keep it limited to just one or two subdomains, the above method will bring your subdomain online in minutes.