• Home
  • Cloud
    • General
    • SaaS
    • BPaaS
    • PaaS
    • IaaS
    • Other Internet Hosted Applications
      • WordPress
        • WooThemes Canvas
          • WooThemes Canvas CSS
  • About me
  • Why Badly Wired?
  • Contact

Badly Wired

Alan's technical notebook - WordPress and other stuff

You are here: Home / Code snippets / Using GIT to deploy scripts to production servers

Using GIT to deploy scripts to production servers

21st December 2016 by Alan Leave a Comment

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

This is how I use GIT to deploy script configurations to multiple servers.

In this instance I have fail2ban  configuration that I want to be able to deploy to multiple servers easily & quickly

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

I assume you are root – otherwise prefix commands with sudo as appropriate

I also assume that you have remote root ssh access ( by  private / public keys is best   of course )

Step 1  Install GIT if you don’t have it , e.g. on Debian

apt-get install git

The key is to set up a GIT directory on the remote server and use the hook to deploy to the correct directory

cd /var
mkdir repo
mkdir f2ban.git && cd f2ban.git
git init --bare

We make a bare repo – the convention is a bare repo directory ends in git

Now we move to the hooks directory

cd hooks

And we need to create a file called post-receive that will process the files on being pushed here

The file needs to contain ( use vim or similar )

git --work-tree=/etc/fail2ban --git-dir=/var/repo/f2ban.git checkout -f

Basically saying when files come here – put them into the fail2ban directory

And post-receive need to be executable i.e.

chmod +x post-receive

On the localmachine in your git directory you need to add the remote server

git remote add myservername ssh://root@myprodserver/var/repo/f2ban.git

And after normal git adding & committing you can push to your server e.g.

git push myservername master

You can repeat this with different servers or different /var/repo/xxx.gits as rerequired

 

 

 

 

 

 

[Next] Find out where to host WordPress [Read the full article…]

Filed Under: Code snippets, Linux, Server setup, Tech Tips  

About Alan

I'm Alan from Fullworks Digital Ltd, where I develop WordPress Plugins .

My day job consists of developing new code and solutions along with support my WordPress plugin user.

I started as a professional programmer in 1979 and had been involved with the IT of business technology in virtually every area that exist.

Badlywired.com is my technical notebook, my aide memoire of the many interesting facts that I come across and 'how to' recipes of things I do infrequently. As I spend a lot of time gathering parts of solutions from the internet and assembling them into my own solutions, and also just learning how to do things, this blog is one way of giving something back to the online community that has helped me extensively.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Applications
  • Cloud
    • General
    • Google Cloud
    • IaaS
    • Other Internet Hosted Applications
      • Wordpress
        • WooThemes Canvas
        • WooThemes Canvas CSS
    • SaaS
  • Code snippets
  • Discounts
  • Genesis
  • Google Apps for Works
  • Linux
  • News
  • SEO
  • Server setup
  • Services
  • Tech Tips
  • Uncategorised
  • Useful Images
  • Useful Stuff
  • WordPress Hosting
  • WordPress Plugins

Tags

background jobs beadcrumbs bind brandings Cache canvas Centos chrome css fail2ban Find firefox Flash fraud genesis gocardless godaddy Google google maps hackers internet explorer javascript KashFlow Linus linux Magento mapquest maps microsoft mysql news nohup php plugin plugins queens diamond jubilee replace SED SEO skype Varnish Virtualmin Webmin woothemes Wordpress

 

Affiliate and Privacy Notices

This site is free to use, but hopes to cover some costs through affiliate income, some products and links are affiliates and may earn the site advertising income.

Some affiliates use Cookies to track if you purchase from them, this allows them to apportion revenue to us you will need to refer to their specific privacy notices as to how you are tracked.

This site is a participant in the Amazon EU Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.co.uk.

  • Privacy Policy

Copyright © 2021 · Badly Wired