A virtual directory is a convenient way to map a specific folder on your server to a URL path, allowing you to serve content from different directories without having to relocate files.
This is particularly useful for hosting multiple applications or services under a single domain.
Plesk makes it easy to create and manage virtual directories, which can be used for various purposes like organizing media files, hosting different web applications, or managing complex site architectures.
Table of Contents
What is a Virtual Directory?
A virtual directory behaves like a subdirectory of your website but points to a different location on your server. For example, you can map https://example.com/app
to a folder located elsewhere on the server, such as /var/www/app/
.
This feature is especially useful for:
- Hosting multiple applications under one domain
- Organizing different sections of a website (e.g., blog, admin, user area)
- Serving static files like images, documents, or videos from different locations
Steps to Create a Virtual Directory in Plesk
1. Log in to Plesk
Access your Plesk control panel by logging in with your credentials.
2. Navigate to Domains
Go to the ‘Domains’ section and select the domain for which you want to create a virtual directory.
3. Access the Virtual Directories Section
- Under your selected domain, look for the option labeled ‘Virtual Directories’ (typically found under the ‘Websites & Domains’ tab).
- Click on ‘Virtual Directories’ to open the management panel for this feature.
4. Create a New Virtual Directory
- Once inside the Virtual Directories panel, click ‘Add Virtual Directory’.
- A form will appear where you can configure the directory settings.
5. Configure the Virtual Directory
- Directory Name: Enter the desired name for your virtual directories (this will be part of the URL path).
- For example, if you enter
app
, the virtual directory URL will behttps://example.com/app
.
- For example, if you enter
- Physical Path: Enter the path to the folder on the server where the content is stored. If the folder doesn’t exist, Plesk will create it for you.
- Permissions: Set the appropriate permissions for the directory. You can configure:
- Read: Allows users to read the contents of the directory.
- Write: Allows modification of files.
- Script source access: Allows viewing of the source code for scripts.
- Execute permissions: Allows script execution (e.g., PHP or ASP.NET).
- Application Settings (Optional): If the virtual directories will host an application, you can choose to turn it into a web application by selecting the appropriate options (e.g., PHP, ASP.NET).
6. Save the Virtual Directory
After configuring the necessary details, click ‘OK’ or ‘Apply’ to save the virtual directory. Plesk will create the virtual directories and map it to the URL path you specified.
Additional Configuration Options
Once the virtual directory is created, Plesk allows further customization:
- Web Application Settings: If you’re using the virtual directories to host a specific web application, you can configure additional settings like custom error pages, document root, or enable/disable directory browsing.
- Access Control: You can restrict access to your virtual directories by IP address or require user authentication for enhanced security. This is particularly useful if the directory contains sensitive information or is only intended for internal use.
- SSL/TLS Configuration: Ensure your virtual directories uses secure connections by enabling HTTPS. You can set up an SSL certificate for the main domain, and it will also cover the virtual directory.
- MIME Types: Define specific MIME types for files in your virtual directory if necessary, allowing proper handling of custom file types or media.
Common Use Cases for Virtual Directories in Plesk
- Hosting Multiple Web Applications
- You can host multiple web applications under the same domain using different virtual directories. For example:
https://example.com/blog
for your WordPress blog.https://example.com/shop
for an eCommerce platform.
- You can host multiple web applications under the same domain using different virtual directories. For example:
- Serving Static Content
- If you have media files or static content (like images or documents) stored in a different location, you can map a virtual directories to serve those files under a specific URL path.
- Segmenting Website Sections
- Larger websites often have different sections (e.g.,
admin
,user
,support
) that can be hosted as separate virtual directories to better organize content and improve scalability.
- Larger websites often have different sections (e.g.,
- Custom Applications or Admin Panels
- Host custom-built applications (e.g., internal tools or admin dashboards) in virtual directories to keep them separate from the main website files.
Managing and Editing Virtual Directories
Once a virtual directory is set up, you can easily manage or modify its settings in Plesk:
- Editing the Physical Path: You can change the folder location or update the directory name by returning to the Virtual Directories section.
- Removing a Virtual Directory: If you no longer need the virtual directories, you can delete it by selecting the directory and clicking ‘Remove’. This will only remove the mapping and will not delete the files.
Conclusion
Creating and managing virtual directories in Plesk is a straightforward process that can greatly enhance the structure and organization of your website or web applications.
Whether you’re looking to host multiple applications under one domain, organize static content, or streamline complex site architectures, Plesk’s virtual directory feature gives you the flexibility and control needed to manage everything efficiently.