Knowledgebase

Running Laravel on Shared Hosting Print

  • developersgitdeployment, developers, webhosting, permissions, cpanel, domain, https, cron, caching, errors
  • 0

The framework works well here with correct setup.

THE DOCUMENT ROOT

Point the domain's document root at the application's public directory, not the project root.

cPanel > Domains > Manage > Document Root.

If the project root is served, your .env file, source code, vendor directory and storage are all publicly reachable. This is the single most serious Laravel deployment mistake.

VERIFYING

Visit yourdomain.com/.env in a browser. You must get Forbidden or Not Found, never content.

CONFIGURATION

APP_ENV set to production APP_DEBUG set to false, always, on a live site APP_KEY set and unique APP_URL set to the https URL

Debug mode on production exposes environment variables and stack traces to anyone who triggers an error.

PERMISSIONS

storage and bootstrap/cache must be writable: 755 with correct ownership, never 777.

DEPENDENCIES

Install with Composer using the no-development flag on production.

SCHEDULED TASKS

One cron entry running the scheduler, which dispatches your defined tasks.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot