티스토리 뷰

2009-05-30 02:30:40

시작전에, I’ll just quickly run through where I put stuff on my server. 아파치 로그와 설정은 각각 다음의 우분투 기본 폴더에 있다: /var/log/apache2 와 /etc/apache2/.

웹사이트: /home/caius/vhosts/<도메인명>/htdocs
Git 저장소: /home/caius/git/<도메인명>.git

~/projects/somesite.com/에 git 로컬 저장소를 가지고 있고, 웹서버에 배포하기를 원한다.
나는 git 저장소를 ~/git/에 보존할것이고, (ssh를 통해) 저장소에 push하면 변경사항들을 웹사이트의 htdocs 폴더에 자동으로 checkout 하도록 설정할것이다.
DNS는 이미 설정됨을 가정하고 (또는 로컬에서 매핑하기위해 ghost를 사용했다.) /home/caius/vhosts/somesite.com/htdocs를 가리키도록 아파치 가상호스트를 설정했다 설정이 적용되도록 아파치를 재로딩했다.

원격 서버

bare git 저장소를 만들고 웹사이트 문서루트의 작업트리를 가리키도록 한다. 이는 모든 git stuff가 somesite.git 폴더에 보존했음을 의미한다, 그러나 그들 파일 자신들은 웹사이트의 폴더에 check out 된다. 그러면 저장소에 push된 새로운 변경들로 작업트리 폴더를 업데이트 하기 위해 post-receive 훅을 설정하자.
$ cd git
$ mkdir somesite.git
$ cd somesite.git/
$ git init --bare
Initialized empty Git repository in /home/caius/git/somesite.git/
$ git --bare update-server-info
$ git config core.worktree /home/caius/vhosts/somesite.com/htdocs
$ git config core.bare false
$ git config receive.denycurrentbranch ignore
$ cat > hooks/post-receive
#!/bin/sh
git checkout -f
^D
$ chmod +x hooks/post-receive

로컬 서버

그리고 이제 클라이언트에서 원격 저장소를 git remote로 추가하고 그것에 push 하자.
$ git remote add web ssh://myserver/home/caius/git/somesite.git
$ git push web +master:refs/heads/master
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://myserver/home/caius/git/somesite.git
 * [new branch]      master -> master

마무리

이제 somesite.com로 이동한다면 git 저장소의 내용들을 볼수 있을것이다. (somesite.com는 예제 url 일 뿐, 소유하고있지는 않다!)

유용한 URL들


태그들: geekprogrammingcodeclibashgitwebsitedeployment and ssh


댓글