Header

Setting Up Git-Based Deployment on a Virtual Private Server (VPS)

Devops & Infrastructure, Git, Tips & Tricks, and Tutorials

Post Image

Efficient deployment is crucial for modern web applications. In this guide, we'll explore how to set up a Git-based deployment workflow on a Virtual Private Server (VPS), made incredibly simple with DeployHQ.

Why Git-Based Deployment?

Git-based deployment offers numerous advantages:

  • Seamless code synchronization
  • Version control integration
  • Consistent deployment process
  • Easy rollback capabilities
  • Improved development workflow

Prerequisites

Before getting started, ensure you have:

  • A VPS with SSH access (the one of your choice)
  • Git installed on your server (not needed if the setup is using SFTP)
  • Your project hosted in a Git repository
  • A DeployHQ account

Preparing Your VPS for Deployment

1. Create Deployment Directory

# Navigate to your web directory
cd /var/www/

# Create project directory
mkdir myproject
cd myproject

2. Set Up SSH Access

Ensure your VPS is configured with SSH access:

  • Generate SSH keys
  • Add public key to server's authorized_keys
  • Configure proper permissions

Integrating with DeployHQ

Instead of manually configuring complex deployment hooks, DeployHQ provides a straightforward solution:

1- Connect Your Repository

  • Link your Git repository (GitHub, GitLab, Bitbucket)
  • Select the branch you want to deploy

2- Configure Server Details

  • Add your VPS connection information
  • Specify deployment path
  • Set up any necessary build or deployment commands

Sample DeployHQ Configuration

# Example deployment configuration
deployment:
  server: your-vps-ip
  path: /var/www/myproject
  branch: main
  build:
    - npm install
    - npm run build
  after_deploy:
    - sudo systemctl restart your-app

Deployment Workflow

With DeployHQ, your deployment becomes as simple as:

  1. Push code to your configured branch
  2. DeployHQ automatically handles the rest
  3. Receive instant deployment notifications

Best Practices

  1. Use environment-specific configurations
  2. Implement proper access controls
  3. Set up deployment notifications
  4. Utilize DeployHQ's rollback features

Advanced Deployment Strategies

While basic Git deployment works well, consider:

  • Multi-environment deployments
  • Automated testing
  • Containerization
  • Continuous Integration workflows

Why Choose DeployHQ?

Our platform offers:

  • Zero-downtime deployments
  • Instant rollbacks
  • Comprehensive deployment logs
  • Multi-server support
  • Easy integration with popular repositories

Conclusion

Git-based deployment doesn't have to be complicated. With DeployHQ, you can transform your deployment process from a complex task to a seamless, automated workflow.

Start Your Free DeployHQ Trial here!

A little bit about the author

Facundo | CTO | DeployHQ | Continuous Delivery & Software Engineering Leadership - As CTO at DeployHQ, Facundo leads the software engineering team, driving innovation in continuous delivery. Outside of work, he enjoys cycling and nature, accompanied by Bono 🐶.

Tree

Proudly powered by Katapult. Running on 100% renewable energy.