How to Create Subdomain and Setup SSL in cPanel?
Nowadays almost all hosting companies offer free SSL certificate using Let’s Encrypt. This makes easy for webmasters to have secured site with HTTPS protocol. Also you can add unlimited or certain number of subdomains to your main site based on your hosting plan. With this subdomains and SSL, you can setup secured sites out of your main site.
Subdomain and SSL
You may wondering why should you create a subdomain when main site is available. There are many reasons for creating a subdomain.
- Site speed – by hosting complex stuffs separately on a subdomain will not affect the loading speed of your main site. For example, you can offer eBooks separately which in general will affect the loading speed up to 1 second.
- Forums – it is very popular to offer forums in a subdomain due to the complexity and the need of separate maintenance.
- Free – subdomain is free as long as your main domain and hosting accounts are valid. This means you don’t need to pay additional for having a separate site.
- Different applications – having a separate subdomain will allow you to have any type of application installed on it independent of the main site. For example, you can have WordPress installed on your main site while phpBB forum on the subdomain.
- Hosting images – it is also possible to host all media content outside the main site so that they will load in parallel and improve page loading speed.
Better examples are creating forum, writing blog or offer some tools in a separate subdomain.
How to Create Subdomain in cPanel?
The number of subdomains that you can add to a main domain depends on your hosting plan. Generally, it is unlimited for VPS or cloud hosting and limited for shared hosting accounts. Even it is limited, we believe you can’t have 10+ subdomains and manage them as an individual. We will explain how to create subdomain in cPanel using SiteGround account. This will be similar in other cPanel based hosting companies like Bluehost, HostGator, etc.
Go to your cPanel and search for “Subdomains”. As you can see in the below screenshot, the option can be seen under the group called “Domains”.
Click on the “Subdomains” icon to go to the subdomain creation screen. Let us create a subdomain named “tools.webnots.com”.
Enter “tools” in the subdomain text box and choose the main site from the next dropdown. You will see the document root gets updated automatically. There should be a green tick mark indicating the entries are correct.
Clicking on the “Create” button will create a new subdomain like “tools.webnots.com”. You will get a success message after creation and the new subdomain will be added to the list of available subdomains. If you want to create the subdomain with “www” then enter “www.tools” instead of “tools”.
Later at any point of time you can remove the subdomain when you don’t need it. Generally you should delete the subdomain after destroying the application installed on it or after backup the content.
Installing SSL Certificate in Subdomain
Now that we have created a subdomain, let’s open it in the browser. Oops!!! You will get a privacy error like below because any URL on the site should have a valid SSL certificate. Since the subdomain doesn’t have it, you will see the privacy error. This happens because we have forced all traffic to the site using HTTPS protocol. So even when try to open “http://tools.webnots.com”, it will be redirected to “https://www.webnots.com/seo-tools” and throw error.
Installing SSL with Free Let’s Encrypt
Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit by the Internet Security Research Group (ISRG). It makes it possible to obtain browser-trusted certificates for your domains at no cost that renew automatically.
Go back to your cPanel and search for Let’s Encrypt option. It should be available under “Security” or similar panel like below.
Click on the “Let’s Encrypt” icon and go to SSL certificate creation screen. Select the subdomain, provide your email id for notification and click on “Install” button.
The installation process will start and run for few minutes.
After completion, you will see a success message similar to the below one.
The subdomain can be seen under the certificate installed list and click on the “Details” button to view the details of encoded certificate, private key and intermediate certificates.
Steps to be Done After Subdomain Creation
Now open the subdomain in a browser, you should probably see the directory structure like below. Remember the Let’s Encrypt SSL certificate is active instantly and your subdomain will work through HTTPS.
Since any users can also view the directory structure of the subdomain, we recommend either to disable directory browsing in .htaccess or install the required application immediately. If you install WordPress then setup maintenance mode and disable search engine indexing. This will ensure that users and search engines will not get any under construction details. Check out article on checklist for new WordPress site to learn more.