Deploy Static Sites on VPS

This post shows a way to deploy static sites on VPS.

First, install necessary applications and configure web server properly.

Then create a bare git repo.

git init --bare /path/to/repo/blog.git

Add a hook to make the repo's content visible. Create a file named post-receive in /path/to/repo/blog.git/hooks directory, and add these content.

#!/usr/bin/bash
rm -rf /path/to/repo/blog/*
git --work-tree=/path/to/repo/blog --git-dir=/path/to/repo/blog.git checkout -f

Make sure the root directory of your site is /path/to/repo/blog.

At last, create a repo in local machine.

git init
git remote add origin root@your.domain:/path/to/repo/blog.git

Now you can do anything you want with Git, just like what you do in GitHub.