Is it possible that mod_vhost_alias can read several directories (For example, each users) to find the sites? Like in a hosting setup where different users can create the directories in their home directory?


vhost_alias maps a domain received into a path on the filesystem. It doesn't read the existing filesystem prior to serving the request to see if the files exist.

However, you can do something like have a stable directory listing of files, and use symlinks or bind mounts in the user directories to point to the actual web directories.

/var/www/domain.com /var/www/domainb.com

and then

/home/user/domain.com is a symlink or bind mount to /var/www/domain.com /home/userb/domainb.com is a symlink/bind mount to /var/www/domainb.com

Remember that mod_vhost_alias runs everything as the user running the apache service. In a shared environment, make sure you know the ramifications for running apache like this.

| improve this answer | |
  • Alright, sweet. Any quick ways to automatically make all those symbolic links? – Kyle Mar 31 '10 at 11:00
  • When the domain is created, create the domain and the user's symlink. If you are doing it the opposite direction where a user creates a domain directory, uploads content, your script would need to move that to the proper location and leave a symlink in place. Some FTP software won't properly traverse symlinks which is why I suggested the bind mount. With a bind mount, you need to update your /etc/fstab so that the mount comes back if the machine is rebooted. – deleted Mar 31 '10 at 15:29

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.