Website Directory Structure and How to Get the most of yours - Plesk Tips

Website Directory Structure – How To Get The Most From Yours With Plesk

When you create a website, Plesk Onyx adds a new virtual host to the web server and creates the site’s directory structure too, filling each of them with essential content. These directories sit in the corresponding virtual host directories:

  • On Linux: /var/www/vhosts/<domain_name>
  • On Windows: C:\inetpub\vhosts\<domain_name>

<domain_name> is where the website’s domain name goes. The directory structure is defined by the default virtual host template

If you want to change the files and directories included in new sites, like for instance, you want to add some scripts or make changes to the error pages, you can define a custom virtual host template. Resellers can also customize virtual host templates for their customers.

Note: Subdomains have equal status with domains and employ the same website directory structure. So, they have a separate directory in /var/www/vhosts and their own configuration files, like php.ini or vhost.conf.

Defining a custom document root in the directory structure

Plesk sets the httpdocs directory as the Document Root directory for all hosted domains by default. But you will find that a lot of current web development frameworks will expect that a different directory, such as, <app_root>/public will be used as the document root. But, using Plesk you can change the default Document Root directory by altering the panel.ini file like this:


docroot = "new_default_docroot"

where <new_default_docroot> is the name of a directory or a directory path (e.g. “new_docroot” or “<domain>/public”).

You can only use these characters in the name of the Custom Document Root:

  • Slash (/)
  • Period (.)
  • Hyphen (-)
  • Word characters:
    • Alphabet letters A-Z (upper or lower case)
    • 0 to 9 digits
    • Underscore (_)

Note that the changes will apply to all newly created domains, but not to any previously existing domains. The path is relative to the webspace root, and you can use the <domain> environment variable that is replaced with the domain’s name on hosting creation.

Creating a custom virtual host template

Creating a custom virtual host template is straightforward. Just create a directory on your local file system, then add one or more of the following directories inside it:

  • cgi-bin so you can include custom scripts in the template.
  • httpdocs if you would like to include custom documents such as web pages or images.
  • error_docs if you want to include custom error messages.
  • webspace to include custom files that will be placed in the subscription home directory (for example, .bashrc, .vimrc, etc.)

After you have created the directories, put the files like to see included in the newly created domains’ virtual host structure in the corresponding directories. You can use the default files stored in the /var/www/vhosts/.skel/0 on Linux or C:\inetpub\vhosts\.skel\0 on Windows if you wish.

You can also use variables in the custom virtual host template. These will be substituted with the corresponding values after the domain creation:

  • @[email protected] – Use the domain name in place of this variable. Used on Linux and Windows.
  • @[email protected] – Use the customer’s email address in place of this variable. Used on Windows only.

When you’ve added all your files, put the directories in a tgz, tar, tar.gz, or a zip archive. Take care that the directories are placed in the root of the archive file and not in a sub-directory. If you include any other directories or files in the root of the archive, Plesk won’t add them to the template for the directory structure.

To upload your custom virtual host template, visit Tools & Settings > Virtual Host Template (in the Tools & Resources group), click Browse, locate the prepared archive file, and then click Send File. To revert to the default virtual host template, click Default.

How useful was this post?

Click on a heart to rate it!

Average rating 4.7 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

Oh no, sorry about that!

Let us know how we can do better below

Tell us how we can improve this post?


Elvis Plesky
Our fun and curious team mascot's always plugged into the latest trends. He's here to share his knowledge and help you solve your tech problems.

    Leave a Comment

    Start typing and press Enter to search