
Let’s face it — not everyone has access to fancy VPS setups or Laravel Forge. If you’re hosting your app on shared hosting with cPanel, you might think deploying Laravel is a nightmare.
But here’s the good news: you can deploy a Laravel app easily using Git and cPanel, no SSH needed. I’ve done it, and I’ll walk you through how to do the same.
Why I Needed This Setup
I had a small Laravel project I needed to push live fast — no budget for VPS, no time to mess with Docker. My client’s hosting provider? Classic cPanel shared hosting, with Git support but no SSH.
This guide is what worked for me, and it’s simple enough for anyone who knows the basics of Laravel and Git.
Step 1: Prepare Your Laravel App for Deployment
Before anything, make sure your Laravel app is production-ready:
- Run
composer install --no-dev
- Set
APP_ENV=production
in your.env
- Set
APP_DEBUG=false
- Compile your assets:
npm run build
If you’re using SQLite or MySQL, make sure your .env
file reflects your shared hosting DB credentials.
Step 2: Set Up a Git Repository in cPanel
Go to your cPanel dashboard → Git Version Control.
- Click “Create” and choose a repository path (e.g.,
/home/youruser/laravel-app
) - Use the “Clone a Repository” option if your code is already on GitHub/GitLab
- If not, just init a blank repo and push manually from local using:
git remote add live ssh://user@yourhost.com/home/youruser/laravel-app
git push live main
Once pushed, your Laravel code now lives inside your cPanel user directory. 🎉
Step 3: Adjust Laravel’s Folder Structure
This part is key.
cPanel’s public folder is usually /public_html
, but Laravel expects a /public
directory.
You have two options:
✅ Option 1: Move /public
to /public_html
- Copy all contents of
/public
into/public_html
- Update
index.php
inside/public_html
:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
Make sure the ../
paths reflect the true location of vendor
and bootstrap
.
✅ Option 2: Point Git repo to a subfolder
If your hosting allows it, set the Git repository inside public_html
and avoid rewriting Laravel structure — but this is more error-prone.
Step 4: Run Laravel Commands via cPanel Terminal or Web Console
If your host supports Terminal, you’re golden. Run:
php artisan config:cache
php artisan migrate
php artisan route:cache
If not, you might need to rely on web-based file managers or CRON jobs to run artisan
commands — clunky, but doable.
Step 5: Set File Permissions (Don’t Skip This)
Inside cPanel file manager:
- Make sure
/storage
and/bootstrap/cache
are writable - Usually this means setting permissions to
755
or775
depending on host
Bonus Tip: Automate Deployment with Git Push
Some cPanel setups allow post-receive hooks or deployment scripts — if yours does, you can automatically run composer install
, clear caches, etc., every time you push.
Final Thoughts
Deploying Laravel to shared hosting with Git and cPanel isn’t as bad as it sounds.
It takes a few extra steps, but once set up, it’s smooth and repeatable.
If you’re building MVPs, small client projects, or budget-friendly Laravel apps — this method is more than enough.
Just be smart about your .env
, folders, and permissions — and you’re good to go!
Pro Tip:
Keep composer.lock
and .env.example
under version control, but never commit your real .env
. Always edit it manually after deployment.