1

I have a Virtualhost made this way:

<VirtualHost *:80>
        Servername www.website.com
        DocumentRoot /path/to/application-1.2.1/client/app/
        ErrorLog /var/log/apache2/logs/application.log
</VirtualHost>

Where application is the application name that changes everytime we deploy a new version, so for example next DocumentRoot would be:

DocumentRoot /path/to/application-1.2.2/client/app/

Is it possible to make a virtualhost with a wildcard or something like:

DocumentRoot /path/to/application-*/client/app/

So that I don't have to change the virtualhost everytime I deploy a new version of the application?

Atropo
  • 145
  • 6

1 Answers1

5

No, you can't have a wildcard there.

Instead, use symlinks:

ln -s /path/to/application-1.2.2/client/app /path/to/application/client/app

and have the config read

<VirtualHost *:80>
        Servername www.website.com
        DocumentRoot /path/to/application/client/app/
        ErrorLog /var/log/apache2/logs/application.log
</VirtualHost>

This has the added bonus that you can keep the old version around for a fast rollback when needed.

Depending on your main configuration, you may need to add

    <Directory /path/to/>
        Options +FollowSymlinks
    </Directory>

to your config, as well.

Jenny D
  • 27,780
  • 21
  • 75
  • 114
  • I'm not sure if it is actually required for a DocumentRoot but most default configurations have the following of symbolic links disabled and you might need a ` Options +FollowSymlinks ` in the virtualhost entry. – HBruijn Apr 10 '15 at 14:07
  • @HBruijn Good catch, I added this to my response. – Jenny D Apr 10 '15 at 14:26