How to deploy PHP/HTML website with Gitlab CI

Setting up Gitlab-CI to deploy your PHP & HTML (or any other ‘static’ site) is quite simple, but poorly documented. After a few weeks of fiddling around I found the following solution. I’d love to hear everyone’s feedback.

Requirements:

  1. Your webserver must have root access (to install the runner).
  2. Your site/codebase should be rather small and not too complex.
    • This example uses rsync to move/sync two folders, so sites that can self-update their DB like wordpress should be OK, but I have not tested it.
    • We’re going to use rsync to move/sync two folders, so sites that self-manage media content, like wordpress, will lose that media content. You will need to tweak the rsync script to handle this yourself.
  3. A gitlab install or repo you have permission to add runners to.
  4. These instructions are for Linux (Ubuntu 14.04 specifically) but they should be applicable to any OS supported by the runner.

Continue reading “How to deploy PHP/HTML website with Gitlab CI”