EN · $ USD
Developer and Application Servers

Automatic Deployment with cPanel Git Version Control

7 min read Updated: Sunucu Atlas technical team

In short

To deploy with cPanel Git, you clone your GitHub or GitLab repository in the Git Version Control tool and add a .cpanel.yml file with your deploy commands to the repo root. For private repos, you generate an SSH key in your cPanel account and add it to GitHub as a deploy key. To ship changes, use Update from Remote and Deploy HEAD Commit; if you push directly to the cPanel repository, the deployment runs automatically.

In this guide
  1. Key Concepts
  2. 1. Create a Deploy Key for a Private Repository
  3. 2. Clone the Repository into cPanel
  4. 3. Define Deploy Steps with .cpanel.yml
  5. 4. Deploying: Pull and Push Methods
  6. Troubleshooting Checklist When Deployment Fails
  7. Best Practices for Safe Deployments
  8. When Is This Approach Not Enough?
  9. Next Step

cPanel's Git Version Control tool connects your GitHub or GitLab repository to your hosting account, so you no longer have to upload files one by one over FTP on every update. You write the deployment steps in a .cpanel.yml file at the repo root, and cPanel runs them in order on every deploy. For private repositories, you add a deploy key to the account. In this guide we'll set it up step by step, with a real Laravel deploy file and a deployment that fires the moment you push to GitHub.

Key Concepts

  • Git Version Control: the tool in cPanel's Files section that handles cloning, updating and deploying repositories.
  • .cpanel.yml: a YAML file in the repository's root directory that lists the shell commands to run during deployment.
  • Deploy key: an SSH key with access to a single repository only. Using it instead of a personal key that can reach every repo in your account is more secure.
  • Pull deploy vs. push deploy: cPanel pulling from the remote repository and publishing (pull), or the deployment running automatically the moment you push directly to the repository on cPanel (push).

This tool requires an account with Git and SSH access. Sunucu Atlas Laravel hosting plans include Composer, Git and Terminal/SSH access together in cPanel.

1. Create a Deploy Key for a Private Repository

If you're using a public repository, you can skip this step and continue with the HTTPS clone URL. With a private repository, cPanel has to prove its identity to GitHub. Open cPanel Terminal (for connection options, see the cPanel SSH access and Terminal guide) and generate a key without a passphrase:

ssh-keygen -t ed25519 -f ~/.ssh/github_deploy -N "" -C "cpanel-deploy"
cat ~/.ssh/github_deploy.pub

The key must have no passphrase, because cPanel performs the pull in the background on your behalf. Next, tell SSH to use this key for GitHub:

cat >> ~/.ssh/config <<'EOF'
Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_deploy
    IdentitiesOnly yes
EOF
chmod 600 ~/.ssh/config

Now paste the .pub output into your repository on GitHub under Settings > Deploy keys > Add deploy key. If the server will only pull code, leave Allow write access unchecked. On GitLab, the same setting is under Settings > Repository > Deploy keys.

Finally, run a test connection once to accept GitHub's host fingerprint. If you skip this, cPanel will throw an unverified host error while cloning:

ssh -T git@github.com

If you see "successfully authenticated", the key works.

2. Clone the Repository into cPanel

  1. In cPanel, open Files > Git Version Control and click Create.
  2. Leave the Clone a Repository option turned on.
  3. In the Clone URL field, enter the SSH address: git@github.com:kullanici/proje.git (for a public repo, the HTTPS URL also works).
  4. In the Repository Path field, enter where the repository will live, for example repositories/proje. Don't clone the repo directly into public_html; the .git folder would be exposed to the web.
  5. Enter a name to show in the list under Repository Name and click Create to start cloning.

3. Define Deploy Steps with .cpanel.yml

The repository is where code waits; the live site sits in a different folder. .cpanel.yml is the bridge between the two. The simplest example for a static site:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/kullaniciadi/public_html/
    - /bin/cp -R dist/* $DEPLOYPATH

A fuller example for a Laravel project; it copies the code to the app folder outside public_html, installs dependencies and refreshes the caches:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/kullaniciadi/laravel
    - /bin/mkdir -p $DEPLOYPATH
    - /usr/bin/rsync -a --exclude='.git' --exclude='.env' --exclude='storage' ./ $DEPLOYPATH/
    - cd $DEPLOYPATH && /opt/cpanel/composer/bin/composer install --no-dev --optimize-autoloader --no-interaction
    - cd $DEPLOYPATH && php artisan migrate --force
    - cd $DEPLOYPATH && php artisan config:cache && php artisan route:cache && php artisan view:cache

Things to watch in this file:

  • The file must be in the repository's root directory and must be committed.
  • The PATH may be restricted in the deploy environment, so writing commands with full paths prevents errors. Composer's path can vary from server to server; check it with which composer.
  • .env and the storage folder are excluded so the server's secret settings and uploaded files aren't overwritten on every deploy.
  • Laravel's initial setup, meaning creating .env and running key:generate, is done once by hand, not in the deploy file. Details are in the how to deploy a Laravel project on cPanel hosting guide.
  • YAML is indentation-sensitive; use spaces, not tabs.

4. Deploying: Pull and Push Methods

Pull deploy (from the cPanel interface)

  1. In the Git Version Control list, click the Manage button next to the repository.
  2. On the Pull or Deploy tab, first click Update from Remote to pull the latest changes from GitHub.
  3. Then click Deploy HEAD Commit to run the .cpanel.yml steps.

Push deploy (fully automatic)

If you add the cPanel repository to your local project as a second remote, every push to it triggers a deployment automatically. You'll find the clone address in the Clone URL field on the Manage screen:

git remote add cpanel ssh://kullaniciadi@alanadiniz.com:22/home/kullaniciadi/repositories/proje
git push cpanel main

Replace the port number with your provider's SSH port. With this method, your local computer's SSH key must be authorized in cPanel.

Automatic deployment when you push to GitHub

If you work as a team, it's more practical to have deployment start the moment changes are merged into the main branch on GitHub. A GitHub Actions workflow that calls cPanel's UAPI commands over SSH does exactly that. First, try the commands by hand in cPanel Terminal:

uapi VersionControl update repository_root=/home/kullaniciadi/repositories/proje branch=main
uapi VersionControlDeployment create repository_root=/home/kullaniciadi/repositories/proje

The first command pulls from the remote repository and the second starts the deployment. Then run them from a workflow you add to the repo. Store the private key and connection details on GitHub under Settings > Secrets and variables > Actions:

name: cPanel Deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: SSH ile deploy tetikle
        env:
          SSH_KEY: ${{ secrets.CPANEL_SSH_KEY }}
          SSH_HOST: ${{ secrets.CPANEL_HOST }}
          SSH_USER: ${{ secrets.CPANEL_USER }}
          SSH_PORT: ${{ secrets.CPANEL_PORT }}
        run: |
          mkdir -p ~/.ssh
          echo "$SSH_KEY" > ~/.ssh/id_ed25519
          chmod 600 ~/.ssh/id_ed25519
          ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts
          ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" \
            "uapi VersionControl update repository_root=/home/$SSH_USER/repositories/proje branch=main && uapi VersionControlDeployment create repository_root=/home/$SSH_USER/repositories/proje"

The key used in this workflow is different from the deploy key: it's generated so GitHub can connect to your server, and its public half is authorized under SSH Access in cPanel.

Troubleshooting Checklist When Deployment Fails

SymptomLikely causeFix
Deploy button is grayed out.cpanel.yml is missing or the repo has uncommitted changesCommit the file at the root; don't edit files by hand in the server-side repo
Cloning fails with "Permission denied (publickey)"The deploy key wasn't added to GitHub or the SSH config is wrongTest with ssh -T git@github.com
Host key verification failedGitHub's fingerprint hasn't been acceptedRun ssh -T git@github.com once in Terminal
Deploy looks successful but the site didn't changeWrong DEPLOYPATH or cachingCheck the path and the config:cache step
Composer command not foundRestricted PATH in the deploy environmentWrite the command with its full path

You'll find deployment logs in the .cpanel/logs folder in your home directory; the error line usually points straight to the problem. All of the tool's options are covered in cPanel's official Git deployment guide.

Best Practices for Safe Deployments

  • Don't edit files in the server-side repository. Every change should be made locally and committed; a file changed by hand on the server blocks the next deploy.
  • Keep secrets out of the repo. The .env file should be in .gitignore and created on the server only once.
  • Use a dedicated release branch. Feed the live site only from the main branch and the test environment from develop, so half-finished work never goes live.
  • Back up before database changes. A backup before a deploy that includes migrate --force makes it easy to recover from a bad migration.
  • Keep deploy keys separate. The key that pulls code from GitHub and the key GitHub Actions uses to reach your server should be different; if one leaks, you can revoke it without disrupting the other.

When Is This Approach Not Enough?

cPanel Git deployment is a simple, reliable solution for PHP projects and static sites. But for projects that build Docker images, need a separate preview environment for every commit, or run always-on services, a platform like Coolify is a better fit; we explain the difference in the automatic deployment from GitHub with Coolify guide.

Next Step

If your team works with Git, keeping staging and production on separate domains in the same account makes life easier. The SA-DEV-2 Laravel hosting plan is a good fit for this setup with 2 addon domains, 10 databases, 3 GB RAM and 3 cores; Terminal/SSH, Composer and Git come ready to use. If you'll host more projects, you can compare all Laravel hosting plans. If you get stuck during setup, you can open a support ticket with the Sunucu Atlas team.

Frequently asked questions

Does cPanel Git Version Control pull from GitHub automatically?

Not on its own. You can pull with Update from Remote in the interface, push directly to the cPanel repository, or automate it with GitHub Actions running uapi commands over SSH.

Why is the Deploy button grayed out?

The repository root must contain a valid, committed .cpanel.yml file, and the server-side repository must have no uncommitted changes. If either condition isn't met, deployment won't run.

What's the difference between a deploy key and a personal SSH key?

A deploy key can access only one repository and is read-only by default. A personal key grants access to every repository in your account, so storing it on a server is riskier.

Can I clone the repository directly into public_html?

It's not recommended, because the .git folder and configuration files could become reachable from the web. Clone the repo into a separate folder and use .cpanel.yml to copy only the files you need into the web directory.

Do composer and artisan commands work in .cpanel.yml?

Yes, as long as your account has Composer and command-line PHP access. Because the PATH may be restricted in the deploy environment, writing commands with their full paths is recommended.

For this guide

Recommended plans

Our Laravel hosting plans include Git, Composer and Terminal/SSH access together in cPanel, so you can connect your GitHub repository and set up automatic deployment with .cpanel.yml right away.

SA-DEV-1

cPanel
Recommended

40 GB NVMe disk

$0.69/mo

+VAT

  • Processor2 cores
  • Memory2 GB
  • LocationIstanbul
  • Terminal / SSH Access (cPanel)
  • Composer and Git
  • Node.js and Python App Manager
  • PHP version selection (up to 8.5)

SA-DEV-2

cPanel

60 GB NVMe disk

$0.98/mo

+VAT

  • Processor3 cores
  • Memory3 GB
  • LocationIstanbul
  • Terminal / SSH Access (cPanel)
  • Composer and Git
  • Node.js and Python App Manager
  • PHP version selection (up to 8.5)

SA-DEV-3

cPanel

80 GB NVMe disk

$1.37/mo

+VAT

  • Processor4 cores
  • Memory4 GB
  • LocationIstanbul
  • Terminal / SSH Access (cPanel)
  • Composer and Git
  • Node.js and Python App Manager
  • PHP version selection (up to 8.5)

Laravel Hosting — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.