I have a website www.mysite.com This is the main site and I will be using the Django web framework for the site

I also want to have other subdomains such as:

I want to know:

  1. Can I do this (use Apache and sub domains to serve different applications)
  2. What are the steps required to set up sub domains and have different web frameworks/applications coexist
  • Zimbra is not likely to work well along other web apps, it is usually recommended to set it up separately – dyasny Aug 7 '14 at 13:29

Of course you can do this.

Subdomains are just separate VirtualHost configurations. The names don't matter. i.e., to Apache, mail.domain.com and mail.anotherdomain.com are as different as mail.domain.com and mail2.domain.com.


  ServerName mail.mysite.com
  DocumentRoot /home/mysite.com/sites/mail/public_html
  ServerName admin.mysite.com
  DocumentRoot /home/mysite.com/sites/admin/public_html

etc. Repeating VirtualHost sections for each site. The DocumentRoot path is arbitrary. It could live in /var/www (which is common on some Linux systems), or wherever. If the system only has one domain on it, and you want the subdomains to seem more separate (and be owned by different users for SuExec purposes, which may be advisable from a security perspective), you could create a separate user for each domain and put them into their own home directories. But, home directories are also arbitrary, so you could have multiple users with the above example Apache configuration. But, you may want to make them /home/mail, /home/admin, /home/otherstuff, if they don't need to share access to files.

Note: if your system has SELinux or AppArmor, the location of DocumentRoots may be fixed by your OS or the Apache package you're using. Likewise, if you use SuExec, the path is often compiled into the suexec binary (it is configurable on Debian and Ubuntu when you use the suexec-custom package, it is hardcoded to /var/www on CentOS, unless you install a different Apache build or rebuild Apache yourself). So, it may be easiest for you to use the default path unless you have reasons to choose others. I like for users to live in /home however, so I use a rebuilt Apache package with suexec set to /home on my CentOS systems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.