Manage your website through Git

Ever wondered how you can update your website (in our case a static website with a bunch of HTML and PHP files) by committing to a Git repository hosted on a different server? if the answer to the previous question is yes, then you are in the right place.

The scenario:

– Website hosted on server A.
– Git repository hosted on server B.

and a few details about why would you opt for maintaining your website through Git:

  1. You need multiple people to access the static content of your website and you also want to maintain all the history of changes together with all the Git’s magic.
  2. You think using an FTP server is not secure enough.
  3. You think giving out SSH access or more permissions on the server to multiple users it’s not what you want. (also using scp will overwrite the files directly with all its consequences)

the setup, on server A:

1. Clone the Git repository over the directory that your Web server will serve.

2. Grab the needed package:

3. Set up a “topic” (called website_update) that will call a ‘git pull‘ each time the repository hosted on server B receives an update. (the file has to be placed into the /etc/fishpoll.d directory)

4. Add a little configuration file that will enable the website_update‘s topic at daemon’s startup. (you should name it website_update.conf)

5. Open the relevant port on Iptables so that server A and server B can communicate as expected, the daemon runs over port 27527.

6. Start the daemon. (by default, logs are sent to syslog but you can run the daemon in Debug mode by using the -D flag)

and on server B:

1. Grab the needed package:

2. Configure the relevant Git hook (post-update, located into the hooks directory) and make it executable.

Finally test the whole setup by committing to the repository hosted on server B and verify your changes being sent live on your website!

Share on Google+9Tweet about this on TwitterShare on Facebook0Share on LinkedIn0Digg thisShare on Reddit0Share on StumbleUpon0Email this to someone