Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have just started a server with debian,

I'm new to this sort of thing so please bare with me.

What I'm trying to achieve is this:

Request comes in : sub.mydomain.co.uk

I have to DocumentRoot setup as /var/www/common

I make a symbolic link in /var/www/common like "ln -s /home/user/folder/ sub.mydomain.co.uk"

How do i get apache to recognize that as a user directory and follow it.

Thanks.

share|improve this question

migrated from stackoverflow.com May 4 '13 at 1:11

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

I'm not sure if this is exactly what you need but should be enough to start. First of all, www-data user (debian's default for apache) have to have access to /home/user/folder

You can then create new configuration for apache in file /etc/apache/sites-available/virtuals

<VirtualHost *:80>
    DocumentRoot /var/www/common/default/
    VirtualDocumentRoot /var/www/common/%0

    <Directory />
            Options FollowSymlinks
            AllowOverride All
    </Directory>
</VirtualHost>

Then you need to activate this config with

a2ensite virtuals
service apache2 reload

It is probably better to disable default configuration with

a2dissite default
service apache2 reload

In /var/www/common/default should be some default page when non-existent page is requested.

With this config you can simply create directory for any domain you wish to handle on server /var/www/common so http://one.simple.domain.com will be provided from /var/www/common/one.simple.domain.com directory

Also more secure is to set SymLinksIfOwnerMatch instead of FollowSymlinks, see appropriate documentation.

share|improve this answer
    
Hi thanks for this reply, although i get the error - Invalid command 'VirtualDocumentRoot', perhaps misspelled or defined by a module not included in the server configuration –  Matt256 May 8 '13 at 18:05
    
Ah i solved that issue, now it works. Thanks –  Matt256 May 8 '13 at 18:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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