How to setup webmail client on Ubuntu 18.04 server with Apache, not in main web site directory.

Posted October 5, 2020 650 views
ApacheUbuntu 18.04

I have successfully installed and setup postfix. I would like to add webmail to the server. If the site domain is, and the main site directory (served by Apache2) is /var/www/html, I wish to add webmail to the site, but it cannot be in the /var/www/html directory. For example, I would like the webmail folder to be located in /var/www/webmail.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

The idea is to set up an extra virtual host for webmail site in your Apache configuration. You might create a subdomain, e.g., pointing at droplet’s IP, and configure Apache virtual host for that subdomain, entering document root directory (site directory) different to the directory of your main domain ( So, main part of webmail virtual host configuration would look like:

<VirtualHost *:80>
    DocumentRoot /var/www/webmail

Here is the tutorial on that subject (especially step 5):

by Justin Ellingwood
by Kathleen Juell
The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software. In this guide, you will learn how to install an Apache web server on your Ubuntu 18.04 server, as well as information about important Apache files and directories.
  • Hi,

    Thanks for the reply. This is actually the thing I’m getting confused about. Are you saying that I need to register a new domain (e.g. Is there no other way to do this? I would prefer to not have to register a domain just for this purpose.