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.
e.g.:
<VirtualHost 192.168.1.1:80>
ServerName mail.mysite.com
DocumentRoot /home/mysite.com/sites/mail/public_html
...
</virtualHost>
<VirtualHost 192.168.1.1:80>
ServerName admin.mysite.com
DocumentRoot /home/mysite.com/sites/admin/public_html
...
</VirtualHost>
...
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.