How to Deploy Your Git Repo Into a Shared Environment Using Arvixe

This article will show you how to deploy your git repo into a shared environment using Arvixe. This article was originally written by Arlo Carreon over at his website. Stop by and take a look!

Git is rapidally becoming more and more popular; and while Github is a great way to store your projects, you will need a way to deploy your web app to your shared hosting. Arvixe is one of the most affordable and reliable shared hosting providers I’ve come across and a perfect example for demonstrating how to deploy your git repo into a shared environment.

1.) Setup SSH Access with Arvixe

Make sure you have SSH access. Shared hosting accounts with Arvixe do not come with SSH access by default. You will to go to the support chat and ask for SSH access, this will only take minutes and is effective immediately. Once they give you access, make sure you can login. Here is how you would SSH into your account with your Arvixe username and password.

[tage lang="bash"]
ssh USER-NAME@your-domain.com

Enter your password: *********
[/code]

Get your public key into Arvixe.Your public key is located on YOUR computer, ~/.ssh/id_rsa.pub.

Create the following file on Arvixe and copy the contents of your public key into this new file: ~/.ssh/authorized_keys.

Incase you don't have ~/.ssh/id_rsa.pub on your computer, run ssh-keygen in your console and hit enter all the way through. At the end of that, you will have the ~/.ssh/id_rsa.pub file on your computer.

You can create a new file on Arvixe with the following command: touch ~/.ssh/authorized_keys.

Configure your repo on Arvixe. First, you need to set a config option in your Arvixe repo to accept pushes into this working directory. While SSH'd into your Arvixe account, navigate to your repo directory and run this command:

git config receive.denyCurrentBranch ignore

Finally, you need to set a git hook that will refresh your working directory after the push has been accepted. Save the following content in:

PATH_TO_REPO/.git/hooks/post-receive

.

#!/bin/sh
# Save this in: PATH_TO_REPO/.git/hooks/post-receive
GIT_WORK_TREE=../ git checkout -f

Then, make it executable with

chmod +x PATH_TO_REPO/.git/hooks/post-receive

2.) Setup Your SSH Config Locally

Automate SSH connection for your Arvixe account.
In order to add Arvixe as a git remote, you want to setup your username as the default and you will not be using your password for authentication. You need to edit/create the file ~/.ssh/config on your computer. Then add this content.

Host your-domain.com
  User YOUR-ARVIXE-USERNAME
  PreferredAuthentications publickey

Now, you should be able to login with ssh your-domain.com without needing to type your password or include your username. If this is not the case, start over at step 1.

3.) Setup Arvixe Account as a Git Remote

Add your domain as a remote. On your computer, navigate to your git repo and run this command.

We are assuming your git repo is in WWW. In reality, your repo can be anywhere on your Arvixe account, just change "www" with the correct path below.

git remote add arvixe-live your-domain.com:www/

Now, you can make your changes to your repo and when you are ready to push your changes:

git push arvixe-live master

Something to think about

With this setup it is now easy to have a "dev" site on your Arvixe account too. SSH into Arvixe and replicate your repo into a different folder (~/www/dev). Locally, setup a new remote:

git remote add arvixe-dev your-domain.com:www/dev

So, from now on you can git push arvixe-dev to test out your new changes. When you are ready to make your changes live: git push arvixe-live.

Tags: , , , , , , , , , | Posted under Internet, Using Arvixe | RSS 2.0

Author Spotlight

Arian Jahansouz

Arian Jahansouz

Hello, I am Arian! I have been writing for Arvixe since 2009 and now head the Arvixe Blog. Feel free to contact me at any time with questions or comments!

3 Comments on How to Deploy Your Git Repo Into a Shared Environment Using Arvixe

  1. Brian says:

    Hey, great step by step. Here is one missing step though, and thought it could be useful to others:
    After this step:
    Configure your repo on Arvixe. First, you need to set a config option in your Arvixe repo to accept pushes into this working directory. While SSH’d into your Arvixe account, navigate to your repo directory
    And before you execute the next step, you may need to initialize Git if you haven’t used it before.
    To do that, run this command:
    git init
    Then do the next step (pick up right where you left off), run command:
    git config receive.denyCurrentBranch ignore
    And just continue with the rest of this tutorial.

    Hey, thanks again, it was a huge help!

  2. Brian says:

    Does this works with the New Windows 2012 servers?

Leave a Reply

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


4 − 3 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>