A subdomain is an additional address created based on the main domain, allowing you to host separate pages, sections, or whole websites. For example, for the domain example.com
, a subdomain might look like test.example.com
or shop.example.com
.
Creating a subdomain may be necessary to separate website content logically. For instance, you can host a blog separately from an online store or allocate language versions of the site (en.example.com, fr.example.com). Subdomains are also used to test new site features, run marketing campaigns, or host separate services such as support (support.example.com). This approach helps organize the site structure, improve user experience, and increase SEO effectiveness.
In this article, we will go through an essential guide for creating a subdomain on your server, focus on Nginx, Apache, and ISPManager panel settings, and discuss availability checks and possible issues.
First, ensure your VPS server is available and you have root rights or the ability to use sudo. Before you start, update the DNS records at your registrar by adding an A-record for the new subdomain pointing to the host’s IP address. Without proper DNS configuration, the browser will not find the resource, making any further actions pointless. Once DNS is ready, proceed to the server configuration.
Go to the /etc/nginx/sites-available/
directory:
cd /etc/nginx/sites-available
Create a new configuration file for your subdomain (e.g., sub.conf
):
sudo nano sub.conf
Insert the following configuration block, replacing sub.example.com
with your subdomain and /var/www/sub/
with the path to your site directory:
server {
listen 80;
server_name sub.example.com;
root /var/www/sub/;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
If you are using HTTPS, you need to add SSL/TLS configuration. Save the file (Ctrl+O) and exit the editor (Ctrl+X).
Create a symbolic link to your configuration file in the /etc/nginx/sites-enabled/
directory:
sudo ln -s /etc/nginx/sites-available/sub.conf /etc/nginx/sites-enabled/
Before restarting Nginx, check the configuration for correctness:
sudo nginx -t
If there are errors, fix them in the configuration file.
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Go to the /etc/apache2/sites-available/
directory:
cd /etc/apache2/sites-available
Create a new configuration file for your subdomain (e.g., sub.conf):
sudo nano sub.conf
Insert the following configuration block, replacing sub.example.com
with your subdomain and /var/www/sub/
with the path to your site directory:
ServerName sub.example.com
DocumentRoot /var/www/sub/
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
ErrorLog ${APACHE_LOG_DIR}/sub-error.log
CustomLog ${APACHE_LOG_DIR}/sub-access.log combined
If you use HTTPS, you will need to configure SSL/TLS in this file. Port 80 should be changed to 443, and certificate-related directives should be added. Save the file (Ctrl+O) and exit the editor (Ctrl+X).
Enable the newly created virtual host:
sudo a2ensite sub.conf
Before restarting Apache, check the configuration for correctness:
sudo apachectl configtest
If there are errors, fix them in the configuration file.
Restart Apache to apply the changes:
sudo systemctl restart apache2
If you use ISPManager, creating a subdomain is even easier since the panel automates many tasks. Simply go to the “WWW-domains” section and click “Add.” In the pop-up window, enter the subdomain name (e.g., test.example.com), choose the file directory (by default, an automatic folder is created in /var/www/), and configure the PHP version and SSL certificate if needed. After clicking “OK,” the configuration will be created automatically, and the panel will adjust the necessary files.
Once you’ve added all the necessary DNS records and configured the web server, ensure the subdomain is working. Enter test.example.com (or any subdomain you created) into the browser address bar and check if the intended page opens. The configuration was applied correctly if an index file (index.html) loads.
If the site does not load, the DNS changes may not have propagated yet — it can take up to 24 hours. Also, make sure the address is typed correctly. Use ping or nslookup tools to check whether the domain record points to your server.
Sometimes, issues arise during creation that prevent the resource from working correctly:
Review every detail to fix errors: verify the configuration, check error logs (e.g., /var/log/nginx/error.log or /var/log/apache2/error.log), and ensure all changes were saved.
Any typo in the conf file can cause the webserver to fail to route requests properly. Don’t forget to use sudo for important commands if you don’t have root privileges.
If you are unable to resolve the issue on your own, consult your web server documentation or ask the community, where users can suggest proven troubleshooting methods.
Learn more about how to purchase a domain, hosting, VPS, or dedicated server.
A domain is the main website address, for example, example.com. A subdomain is the part of the domain that precedes the main name, for example, blog.example.com. Subdomains are used to organize website sections.
Subdomains do not need to be registered separately. They are created within the registered domain through hosting or DNS settings.
The number of subdomains depends on the hosting or DNS settings. Usually, many subdomains can be created, but some hosting providers may impose limits.