Deploying a Git repository directly from a version control platform like GitHub, GitLab, or Bitbucket to your OzSpeed hosting account allows you to easily manage updates and maintain your website’s code. OzSpeed’s hPanel supports Git integration, enabling smooth deployment and updates of your web application. Here’s a step-by-step guide on how to deploy your Git repository using hPanel.
Prerequisites #
Before you start, ensure the following:
- You have a Git repository hosted on GitHub, GitLab, or Bitbucket.
- SSH access is enabled on your OzSpeed hosting account (for command-line operations).
- Your Git repository is set up with the necessary files, including a
.gitignore
file to exclude unnecessary files.
Step 1: Enable SSH Access in hPanel #
- Log in to your hPanel Dashboard at ozspeed.com.au.
- Go to Advanced > SSH Access.
- Click “Enable SSH Access” if it’s not already enabled.
- Note down the SSH login details (hostname, username, and port) provided on this page.
Tip: #
- Use an SSH client like PuTTY (Windows) or the built-in terminal (Mac/Linux) for connecting to your server.
Step 2: Connect to Your Server via SSH #
- Open your terminal or SSH client.
- Connect to your server using the SSH details:
bashCopy codessh your_username@yourdomain.com -p 22
- Enter your password when prompted.
Tip: #
- Replace
your_username
with your actual username andyourdomain.com
with your domain.
Step 3: Navigate to Your Deployment Directory #
- Once logged in via SSH, navigate to the directory where you want to deploy your Git repository (e.g.,
public_html
or a subdirectory):
bashCopy codecd public_html/your_project_folder
- If the folder doesn’t exist, create it using:
bashCopy codemkdir your_project_folder && cd your_project_folder
Step 4: Initialize a Git Repository #
- Initialize a Git repository in your deployment directory:
bashCopy codegit init
- Add your remote Git repository (GitHub, GitLab, or Bitbucket URL):
bashCopy codegit remote add origin https://github.com/yourusername/yourrepository.git
Tip: #
- For private repositories, use the SSH URL instead of the HTTPS URL for better security:
bashCopy codegit remote add origin git@github.com:yourusername/yourrepository.git
Step 5: Authenticate and Pull Your Repository #
- If you’re using an SSH URL for a private repository, ensure your SSH keys are set up:
- Generate an SSH key pair on your local machine:
ssh-keygen -t rsa -b 4096
- Copy the public key:
cat ~/.ssh/id_rsa.pub
- Add the public key to your GitHub, GitLab, or Bitbucket account under SSH Keys.
- Pull the latest version of your repository:
bashCopy codegit pull origin main
Tip: #
- Replace
main
with your default branch name (e.g.,master
,dev
).
Step 6: Set Up Automatic Deployment (Optional) #
To automate the deployment process, you can set up a Git post-receive hook or use a Continuous Deployment (CD) service like GitHub Actions, GitLab CI/CD, or Bitbucket Pipelines.
Example: Git Hook for Automatic Deployment #
- Create a
post-receive
hook in the.git/hooks/
directory:
bashCopy codenano .git/hooks/post-receive
- Add the following script:
bashCopy code#!/bin/bash
GIT_WORK_TREE=/path/to/your/project git checkout -f
- Save and exit (
Ctrl + O
, thenCtrl + X
). - Make the hook executable:
bashCopy codechmod +x .git/hooks/post-receive
Tip: #
- This script checks out the latest code to your project directory after every push.
Step 7: Verify Your Deployment #
- Open your website URL in a browser (e.g., https://yourdomain.com).
- Ensure the latest version of your application is deployed and working as expected.
- Check the logs in the public_html/logs folder if you encounter any issues.
Step 8: Update Your Repository #
To update your deployed application with the latest changes from your Git repository:
- Connect to your server via SSH.
- Navigate to your project folder:
bashCopy codecd public_html/your_project_folder
- Pull the latest changes:
bashCopy codegit pull origin main
Tip: #
- Use
git status
to check the current state of your repository before pulling updates.
Troubleshooting Tips #
- Authentication Errors: Ensure your SSH key is correctly added to your Git hosting account.
- Permission Denied: Check file permissions using
chmod
or usesudo
if needed. - Merge Conflicts: Resolve merge conflicts locally and push the changes before pulling them to your server.
- Deployment Not Updating: Clear the server cache using hPanel’s Cache Manager or manually clear the cache files.
Additional Tips: #
- Use .env Files for Configuration: Keep sensitive data out of your repository by using
.env
files for environment-specific configurations. - Set Up Regular Backups: Use hPanel’s Backup tool to regularly back up your application in case of issues during deployment.
- Enable Error Logging: Use Laravel’s or WordPress’s built-in logging features for better error diagnosis.