Skip to content

Instantly share code, notes, and snippets.

@phoenixlzx
Created January 26, 2016 02:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phoenixlzx/8171b8164b9a9bdc7010 to your computer and use it in GitHub Desktop.
Save phoenixlzx/8171b8164b9a9bdc7010 to your computer and use it in GitHub Desktop.
Deploy Jekyll on VPS using git-hook

Install dependencies

$ apt-get install git nginx # or using any other package manager and web server

Create directories and repositories:

cd $HOME
mkdir -p blog blog.git tmp
cd blog.git
git --bare init

Create git hook

file $HOME/blog.git/hooks/post-receive

GIT_REPO=$HOME/blog.git
TMP_GIT_CLONE=$HOME/tmp/blog
PUBLIC_WWW=$HOME/blog

git clone $GIT_REPO $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit

and chmod +x $HOME/blog.git/hooks/post-receive

Configure webserver

Point your webserver's document root to $HOME/blog and reload it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment