May 27, 2025
If you’re building modern web apps using tools like Vite, Next.js, or Laravel with Inertia.js, you might hit a wall when it’s time to deploy to cPanel. The main issue? cPanel doesn’t support build tools like Vite or Webpack out of the box.
But don’t worry — if you’re on a budget and stuck with cPanel shared hosting, there are still ways to get your app deployed in production. Here’s how.
Shared hosting environments like cPanel typically do not support Node.js environments or terminal access required to run npm install or npm run build. That’s why you need to build your app outside of cPanel — either locally or using CI/CD tools like GitHub Actions.
Understand GitHub Actions first You can start with their official docs.
Generate an SSH key pair locally:
ssh-keygen -t ed25519 -C "your-email@example.com"Add the public key to your cPanel server:
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keysAdd Secrets to your GitHub repo Navigate to: https://github.com/your-username/your-repo-name/settings/secrets/actions
Add the following secrets:
SSH_HOST — your server IP or domainSSH_USERNAME — your cPanel usernameSSH_PASSWORD — optional if using key-based authSSH_PORT — usually 22, but check with your hosting providerSSH_PRIVATE_KEY — your private key content from step 2Add variables to GitHub Actions Navigate to: https://github.com/your-username/your-repo-name/settings/variables/actions
DEPLOY_PATH — the path to your public folder on cPanel (e.g., /home/username/public_html)Example GitHub Actions Workflow Add this file as .github/workflows/deploy.yml:
name: Deploy to cPanel
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Upload build to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
source: 'public/build'
target: '${{ vars.DEPLOY_PATH }}/public/build'Done! Now whenever you push to the main branch, GitHub will build and deploy your app automatically to your cPanel server 🎉
If you don’t want to set up GitHub Actions, you can always build the app locally and manually upload the output.
Run:
npm install
npm run buildUpload the contents of your /public/build folder to the corresponding folder in your cPanel (e.g., /public_html/public/build).
This is the easiest approach if you’re only making occasional changes.
This method is strongly discouraged, but in case it’s your only option, here’s how to do it.
Remove public/build from .gitignore (if listed)
Build your app:
npm install
npm run buildAdd the build output to Git:
git add public/build
git commit -m "chore: add build files"
git push origin mainOnly use this as a last resort.
next export) — easier to host and faster to load.Deploying modern frontend apps to cPanel may not be ideal, but with the right setup, it’s very much doable — even if you’re on a tight budget. If you ever need more flexibility, you can consider switching to affordable VPS providers like DigitalOcean, Hetzner, or Fly.io.
Good luck, and happy shipping 🚀