FB pixel

How to Create a Subdomain on VPS?

214 09.08.2025

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.

Preparing to create a subdomain

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.

Using Nginx

Creating an Nginx configuration file

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).

Creating a symbolic link

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/

Checking the Nginx configuration

Before restarting Nginx, check the configuration for correctness:

sudo nginx -t

If there are errors, fix them in the configuration file.

Restarting Nginx

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Using Apache

Creating an Apache configuration file

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).

Enabling the virtual host

Enable the newly created virtual host:

sudo a2ensite sub.conf

Checking the Apache configuration

Before restarting Apache, check the configuration for correctness:

sudo apachectl configtest

If there are errors, fix them in the configuration file.

Restarting Apache

Restart Apache to apply the changes:

sudo systemctl restart apache2

Using ISPManager panel

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.

Checking subdomain availability in the browser

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.

Solving everyday problems and errors during subdomain setup

Sometimes, issues arise during creation that prevent the resource from working correctly:

  • Missing or incorrect A-record at the registrar (DNS doesn’t know where to direct the request);
  • Error in the configuration file (missing required line, incorrect server_name, wrong path to directory);
  • Web server restart not completed (Nginx or Apache didn’t reload new settings);
  • Permission issues (directory or index.html file not readable);
  • Configuration conflict due to existing virtual hosts;
  • Premature testing (DNS not updated yet, so the subdomain doesn’t work immediately after creation).

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.

FAQ

What’s the difference between a subdomain and a domain?

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.

Do subdomains need to be registered?

Subdomains do not need to be registered separately. They are created within the registered domain through hosting or DNS settings.

How many subdomains can usually be created?

The number of subdomains depends on the hosting or DNS settings. Usually, many subdomains can be created, but some hosting providers may impose limits.