Deploying Your Git Repo To Arvixe Web Hosting
Git is rapidally becoming more and more popular and while Github.com is a great way to store your projects you will need a way to deploy your web app to your shared hosting. Arvixe.com 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 like Arvixe.com.
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.
ssh USER-NAME@your-domain.com ... Enter your password: *********
Get your public key into Arvixe.Your public key is located on YOUR computer,
Create the following file on Arvixe and copy the contents of your public key into this new file:
Incase you don’t have
~/.ssh/id_rsa.pubon your computer, run
ssh-keygenin your console and hit
enterall the way through. At the end of that, you will have the
~/.ssh/id_rsa.pubfile on your computer.
You can create a new file on Arvixe with the following command:
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:
#!/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
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