🏠 Home 👤 About ⚡ Skills 💼 Portfolio 📦 Packages 📝 Blog ✉ Contact ✉ Contact Now
All Articles

Deploying Laravel to Shared Hosting Without Losing Your Mind

No SSH, no symlinks, a document root you cannot change. Plenty of clients are on cPanel, and Laravel can absolutely run there — with a specific set of adjustments.

Junaid Ali 2 min read 0 views

The advice online is "use a VPS". That is correct and frequently irrelevant — the client already has cPanel hosting and is not moving. Laravel runs there perfectly well once you handle four specific problems.

1. The Document Root Problem

Your host serves public_html/. Laravel expects to serve public/ with everything else above it. Never solve this by moving all the Laravel files into public_html — that exposes your .env.

Put the application in a sibling directory (say ~/laravel-app/), put the contents of public/ into public_html/, and fix the two paths in public_html/index.php:

require __DIR__.'/../laravel-app/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel-app/bootstrap/app.php';

2. No Symlinks Means No storage:link

Many shared hosts disable symlink(). Rather than moving uploads into the public folder, serve them through a route with a MIME allow-list and a traversal guard — you keep the safety of storing outside the web root.

3. Permissions

chmod -R 775 storage bootstrap/cache

Getting a 500 with an empty log is nearly always this. The web server user must be able to write both directories.

4. The Scheduler Needs a Real Cron Entry

In cPanel's Cron Jobs, add:

* * * * * /usr/local/bin/php /home/user/laravel-app/artisan schedule:run >> /dev/null 2>&1

Check the PHP binary path — cPanel often has several versions installed and the default may not be the one your app needs.

Deploying Without SSH

Run composer install --no-dev --optimize-autoloader locally, upload the whole thing including vendor/, and use a small maintenance route or cPanel's terminal (if available) to clear caches.

Before You Call It Done

  • APP_DEBUG=false and APP_ENV=production.
  • Request /.env in a browser — you must get a 403 or 404.
  • Confirm HTTPS redirects work.
  • Submit a form and confirm mail actually sends; shared hosts often block external SMTP ports.
Tagged Laravel Deployment Hosting cPanel
Share this article

Want this built properly?

I take on a small number of projects at a time so each one gets real attention.

WhatsApp Teams LinkedIn Facebook GitHub