How to set up multi users on dev server with git and github

gitgithub

I'm working on lamp application. We have 2 servers (Debian) Live and Dev.

I constantly work on dev main to add new features and fix bugs.
When happy all works well I scp the relevant code to the Live system. Database (mysql) is local to each machine.

Now this is pretty basic setup really and I want to improve the workflow a bit. I use git and github for version control. Admittedly I've only really used one branch. Their can be 3 different developers who work on the code at different times. We all use the same linux username to connect to the dev server and edit the code directly when needed. I usually then commit and push the code at the end of the day to github.

One thing to bare in mind is it isn't easy to run this code on a local machine as there are many apache and subdomain configurations that wouldn't work on a local machine so it is important to work on the dev server not locally.

I need to create a new process because we need to have a main trunk now and a branch with a big code re-write.

What is the best way to do this. Should I create different unix logins for each developer and set up different working areas on the dev server for there changes? e.g.

/var/www/mysite_derek
/var/www/mysite_paul
/var/www/mysite_mike

my thinking is they can do a pull from the main branch and then create there own branch and merge it back in. I'm not sure how this will work though with git locally and with github.

will i need to create different github user accounts as well.

I'd like to do this the 'right' way and future proof for having lots of potential developers but I also don't want to over complicate it. I simple and elegant solution is preferred.

any recommendations or suggestions?

Best Answer

A solution that we use with about 12 developers is the following. It works very well and makes for a flexible setup without needing to modify the server's config anymore. It probably won't scale to 40-50 devs due to network latency and speed of server storage.

We share the /var/www/ tree via Samba, so the Windows clients can use their local IDE's and VCS-clients to edit on the LAMP server. No-one has an account on the Linux server.

Create your directory structure like this:

/var/www/mysite.com/www/derek/
/var/www/mysite.com/www/paul/
/var/www/mysite.com/www/mike/

In your internal DNS, create a wildcard record that points **.dev* to your lamp server's IP address. I'm assuming 123.45.67.89 here.

In Apache, define a virtualhost that looks similar to this:

<VirtualHost 123.45.67.89>
   ServerName lamp.dev
   ServerAlias *.dev
   VirtualDocumentRoot /var/www/%-3.0.%-2/%-4/%1/
</VirtualHost>

The important parts are the ServerAlias wildcard, which makes this vhost respond to all incoming requests that end with '.dev'. The other important one is the VirtualDocumentRoot, which looks complex but isn't so bad. It simply cuts the incoming hostname into parts and constructs the DocumentRoot out of the parts. You can read more about it here.

Now, any developer can visit http://derek.www.mysite.com.dev/ and view their personal working-copy of mysite.

Adding a new site, subdomain or developer is simply a case of creating the right directories on the Samba share.

For deploying to the Production servers, I would recommend you ditch scp and look at Capistrano, and the excellent centralized web frontend Webistrano. Capistrano is a bit Rails-centric, but it only takes a few lines to adapt to PHP for example. Webistrano provides a central GUI where you can deploy or update a site straight from version control at the push of a button. Having easily scripted deployments, that can be repeated reliably and rolled back in case of problems should not be ignored.

Related Topic