DevOps & Cloud intermediate 8 min read • Updated September 26, 2026

Automated Continuous Deployment to cPanel with Git & .cpanel.yml

Establish an atomic, zero-downtime deployment pipeline to shared cPanel hosting directly from your local IDE terminal—eliminating manual FTP uploads and securing credentials.

Automated Continuous Deployment to cPanel with Git & .cpanel.yml
ANSWER-FIRST ARCHITECTURAL SUMMARY
To deploy automatically to cPanel via Git: 1) Configure SSH access on port 2222; 2) Initialize a remote repository outside public_html; 3) Define a .cpanel.yml manifest with copy tasks targeting public_html; 4) Push commits from your local repository with git push origin main to trigger atomic cPanel VersionControlDeployment.

Prerequisites & Environment

  • cPanel Access with Shell / SSH enabled
  • Git installed on local machine
  • Basic understanding of SSH key pairs

Establishing an atomic, zero-downtime deployment pipeline to shared cPanel hosting directly from your local IDE terminal—eliminating manual FTP uploads and securing credentials.

Summary#

Shared cPanel hosting is frequently considered legacy infrastructure due to manual FTP uploads, lack of version control, and brittle configurations. By leveraging native Git repositories inside cPanel paired with .cpanel.yml deployment tasks, you can establish an automated, continuous deployment pipeline from your local terminal.

NOTE
This guide is tested against HostGator, Bluehost, Namecheap, and standard cPanel v110+ running Apache 2.4 and PHP 8.3 Native.

1. The Deployment Architecture#

Traditional FTP approaches suffer from three critical flaws:

  1. No version rollback: Overwriting files in production leaves zero audit trail.
  2. Partial uploads: Dropped network connections during FTP leave the site in an inconsistent, broken state.
  3. Leaked credentials: FTP transmits credentials in plaintext or requires storing passwords in local clients.

The modern cPanel Git architecture resolves this by isolating the repository:

TEXT
Local Workstation (Mac / Linux)
       │  git push origin main
       ▼
HostGator: /home/user/permesh-repo  (Bare or Isolated Git Repository)
       │  Triggered by post-receive / VersionControlDeployment
       ▼
HostGator: /home/user/public_html   (Clean production files only)

2. SSH Configuration & Port 2222#

HostGator and many shared hosts run SSH on Port 2222 instead of standard Port 22 to reduce automated brute-force attempts.

Configure your local ~/.ssh/config:

SSH-CONFIG
Host PerMesh
    HostName 216.172.172.88
    Port 2222
    User octola17
    IdentityFile ~/.ssh/id_rsa
    AddKeysToAgent yes
    UseKeychain yes

Test your SSH connection:

BASH
ssh -p 2222 octola17@permesh.com

3. Creating the Deployment Blueprint (.cpanel.yml)#

cPanel requires a file named .cpanel.yml in the root of your Git repository. It tells the cPanel deployment engine which files to copy into your web root (public_html):

YAML
---
deployment:
  tasks:
    - export DEPLOYPATH=/home1/octola17/public_html
    - /bin/cp -f index.php $DEPLOYPATH/ 2>/dev/null || true
    - /bin/cp -f .htaccess $DEPLOYPATH/ 2>/dev/null || true
    - /bin/cp -Rf assets $DEPLOYPATH/ 2>/dev/null || true
    - /bin/cp -Rf includes $DEPLOYPATH/ 2>/dev/null || true
    - /bin/cp -Rf pages $DEPLOYPATH/ 2>/dev/null || true

4. Key Takeaways#

  • Security First: Keep .git and .env files completely outside public_html.
  • Atomic Sync: .cpanel.yml copies updated files in milliseconds with zero downtime.
  • Git as Source of Truth: Never edit live files via cPanel File Manager; push all changes through Git.

Written by Alex Carneiro

Founder & Systems Architect at PerMesh. Focused on clean production engineering, automated pipelines, and fast web architectures.