---
title: "How to Configure a Separate Folder for a Subdomain in Apache - CloudBlast"
description: "How to Configure a Separate Folder for a Subdomain in Apache"
url: "https://cloudblast.io/es/article/How-to-Configure-a-Separate-Folder-for-a-Subdomain-in-Apache"
language: "es-ES"
---

BLOG

# How to Configure a Separate Folder for a Subdomain in Apache

5€ de saldo gratis al registrarte

Regístrate en CloudBlast y consigue 5€ de crédito en la nube para desplegar tus VPS

[Reclama 5€ gratis](https://console.cloudblast.io/auth/login?ref=2)

-   [Volver](https://cloudblast.io/es)
-   [Todos los artículos](https://cloudblast.io/es/blog)

2024-09-29

### How to Configure a Separate Folder for a Subdomain in Apache

tutorials

**Introduction**
Configuring a separate folder for a subdomain in Apache is a common requirement for web developers who want to organize their web applications efficiently. By setting up subdomains, you can host different parts of your website or entirely separate websites under the same domain. This guide provides a step-by-step approach to configuring a separate folder for a subdomain in Apache, ensuring that your web server is organized and scalable.

**Understanding Subdomains**
A subdomain is a prefix added to your main domain name, allowing you to create separate sections of your website. For example, if your main domain is \`example.com\`, a subdomain could be \`blog.example.com\`. Subdomains are useful for organizing content, hosting different applications, or creating staging environments.

**Prerequisites**
Before configuring a subdomain in Apache, ensure you have the following:
\- A registered domain name.
\- Access to your DNS settings to create subdomain records.
\- An Apache web server installed and running.
\- Administrative access to your server to modify configuration files.

**Step-by-Step Guide to Configuring a Subdomain**
**1\. Set Up DNS Records**
First, you need to create a DNS record for your subdomain. This involves adding an A record or CNAME record in your domain's DNS settings. The record should point to the IP address of your server where Apache is running.

**2\. Create a Directory for the Subdomain**
Next, create a directory on your server where the subdomain's files will be stored. For example, if you want to create a subdomain \`blog.example.com\`, you might create a directory like \`/var/www/blog\`.

> mkdir -p /var/www/blog

**3\. Configure Apache Virtual Host**
Apache uses virtual hosts to manage multiple domains and subdomains. You need to create a virtual host configuration file for your subdomain. This file tells Apache where to find the files for the subdomain and how to handle requests.

Create a new configuration file in the Apache sites-available directory:

> sudo nano /etc/apache2/sites-available/blog.example.com.conf

Add the following configuration to the file:

> <VirtualHost \*:80>
>   ServerName blog.example.com
>   DocumentRoot /var/www/blog
>
>   <Directory /var/www/blog>
>     Options Indexes FollowSymLinks
>     AllowOverride All
>     Require all granted
>   </Directory>
>
>   ErrorLog ${APACHE\_LOG\_DIR}/blog\_error.log
>   CustomLog ${APACHE\_LOG\_DIR}/blog\_access.log combined
> </VirtualHost>

**4\. Enable the New Virtual Host**
After creating the virtual host file, enable it using the \`a2ensite\` command:

> sudo a2ensite blog.example.com.conf

**5\. Restart Apache**
To apply the changes, restart the Apache service:

> sudo systemctl restart apache2

**6\. Test the Configuration**
Finally, test your configuration by accessing the subdomain in a web browser. Navigate to \`http://blog.example.com\` and verify that it serves the content from the \`/var/www/blog\` directory.

**Conclusion**
Configuring a separate folder for a subdomain in Apache is a straightforward process that involves setting up DNS records, creating a directory for the subdomain, and configuring Apache virtual hosts. By following these steps, you can efficiently manage multiple subdomains on a single server, allowing for better organization and scalability of your web applications. Whether you're hosting different sections of a website or entirely separate sites, subdomains provide a flexible solution for managing your online presence.

Compartir

## Sigue leyendo

[2026-07-25 How to Install and Set Up Mailcow on Ubuntu and Debian VPS tutorials](https://cloudblast.io/article/how-to-install-and-setup-mailcow-on-ubuntu-and-debian-vps)

[2026-07-25 How to Install Chatwoot on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-chatwoot-on-ubuntu-and-debian-server)

[2026-07-25 How to Install Mattermost on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-mattermost-on-ubuntu-and-debian-server)

[2026-07-25 How to Install RustDesk on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-rustdesk-on-ubuntu-and-debian-server)
