Let's said that I will have a unique development server sharing code for multiple developers. The code for each developer will be on it's home directory under sources so basically it will be something like ~/<developer_name>/sources. That server is running Apache 2.4.x.

I need that each developer could access their code by for example <developer_name>.domain.com. Off course the developer_name on the URL will match the name on the /home directory.

My solution is a Virtual Host per developer on the Apache config, is there any better solution and I am not aware?

  • 2
    Dynamically Configured Mass Virtual Hosting and a catch-all DNS record and the only thing you need to do is to create user accounts – HBruijn Nov 1 '16 at 15:08
  • @HBruijn thats' exactly what I want to achieve although I am a bit lost about catch-all DNS record, how? what do you mean by this? Sorry for my ignorance this is my first time trying to implement this – ReynierPM Nov 1 '16 at 15:24

We have a similar setup.

The one catch is that you'll want to have a whole subdomain for your server. So instead of jdoe.domain.com & bsmith.domain.com, you'll have jdoe.dev.domain.com and bsmith.dev.domain.com. You can almost think of the 'dev.domain.com' as the server.

You'll probably want to do something like this:

Apache module

Make sure that the vhost_alias module is enabled.

# a2enmod vhost_alias

Apache config

(the key is the VirtualDocumentRoot directive)

<VirtualHost *:80>
  ServerName dev.domain.com
  ServerAlias dev.domain.com *.dev.domain.com
  VirtualDocumentRoot /home/%1/sources

DNS entry

You need a DNS entry to point dev.domain.com and anything under it (*.dev.domain.com) to your development server.

If you want to get rid of the 'dev' subdomain, you'll have to make a DNS entry for every developer.

A BIND record in the domain.com zone could look like this:

*.dev     A

Do you need them to have their own domain names? If not, there is the built-in mod_userdir that will do this. Your developers would be at http://developers.domain.com/~<developer_name>/ (such as /~bob/). You would just define UserDir to be "sources" (the default is public_html).

The config is usually in httpd.conf, but you'd just need something like:

LoadModule userdir_module modules/mod_userdir.so
<IfModule mod_userdir.c>
    UserDir sources

You may also have a UserDir disable that you'll also have to comment out.

  • Sadly yes, the application work with licenses based on domains! but anyway is helpful too I have two ways to get it done now :) – ReynierPM Nov 1 '16 at 22:52

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.