0

I am using github to control the source code of my web application but I am having trouble deploying it on my live server. I would like to ssh onto the server and git pull origin master when I have stable code in the repo. The problem is that I have two folders which reside in different places on the server.

# Bolded to be version controlled
/var
**/var/ci** <- php framework
/var/www/
**/var/www/webapp1**
/var/www/webapp2

My question: Is there a way to set this up such that afterwards I can just git hub pull origin master and it will grab the latest code into both directories?

A solution, although sacrificing ease and peace of mind, would be to set up a repo on the server in a different location but have a bash script to do the replacement of the web app. Would any problems arise from this?

#/bin/bash
#Disclaimer: pseudo code
`git pull origin master`
`rm -rf * /my/live/frameworks`
`cp -f /my/git/repo/frameworks /my/live/frameworks
`rm -rf * /my/live/web_root`
`cp -f /my/git/repo/web_root /my/live/web_root

I can see some problems with the method above:

  1. Non-smooth application upgrade
  2. Losing cached templates and other temp files. I could add a filter on the rm -rf but again this approach is too hacky for me to be comfortable with

If you own a web server and manage it by pulling the latest code out of a repo set up like I do can you please offer some tips on how I should go about doing this? Much appreciated.

Ben Reser
  • 5,695
  • 1
  • 21
  • 29
  • Can't you just make both directories clone from the same git repo? Yes you will still need to do `git pull` in two places, but if that's too much a hassle you can wrap that in a script. I don't understand what you're trying to do there with `cp` and `rm`. If your deployment is a clone of a git repo, then all you should need to do is `git pull` to upgrade and `git checkout -f SOMETAG` to roll back, that's it. Or I don't get your question. – janos Aug 19 '13 at 23:08

1 Answers1

0

If you're set on managing it this way, you could use symlinks to link into the git project from the actual web-exposed directories.

Here's a thorough answer describing that technique.

Community
  • 1
  • 1
Nick Veys
  • 23,458
  • 4
  • 47
  • 64