3

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?

Derek Organ
  • 591
  • 1
  • 10
  • 20
  • You say you need to have a main trunk now as well as a branch ; does that mean there will be multiple dev servers? or still just one? – pjz Jul 13 '10 at 15:28

1 Answers1

5

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.

Martijn Heemels
  • 7,728
  • 7
  • 40
  • 64
  • do u use git / svn with that? – Derek Organ Jun 09 '10 at 12:58
  • one thing the developers are not in one office and the server is a hosting company so I don't think that would work well for that but not sure. its defo interesing though and might lead me to solving my problem a different way. – Derek Organ Jun 09 '10 at 13:00
  • We use SVN with that. Users simply use use their local svn client to checkout to the correct dir on the Samba share. It's slower than your local harddisk, but quite workable on a LAN. SVN doesn't like Samba shares though. Takes a few config tweaks on the server. I'd imagine that Git, Hg or Bzr would be faster and easier due to simpler working-copies. – Martijn Heemels Jun 09 '10 at 21:29
  • 1
    @Derek The samba method would be too slow over the internet, but you could combine it with linux accounts on the server. Would be slow and go against the idea of DVCS though. We use a VPN to access the Samba share and dev server, but I would like to have the speed of a local DVCS back. – Martijn Heemels Jun 09 '10 at 21:41
  • @Derek I edited my answer to provide some info on deployment. – Martijn Heemels Jun 09 '10 at 21:52