If it works with php artisan serve but breaks on your VPS or shared host, you are usually hitting environment and infrastructure differences, not a mystery PHP bug. This guide maps the most common gaps so you can debug production like a checklist instead of guessing.
What artisan serve actually simulates
Laravel’s built-in server is fine for local development: it boots your app, routes requests, and reloads code when you edit files. It does not fully mirror production: process model, timeouts, HTTPS termination, real domain names, reverse proxies, and file permissions can all differ.
When someone says “production is stricter,” they usually mean: different .env, different web user, longer request paths through Nginx/Apache, and no one magic flag that makes the two worlds identical.
1. Environment: APP_ENV, APP_DEBUG, APP_URL
In production, set APP_ENV=production and APP_DEBUG=false. Leaving debug on leaks stack traces and slows the app. APP_URL should match the public URL you serve (scheme + host, no trailing slash). Wrong APP_URL breaks signed URLs, some redirects, and link generation in emails.
If assets load over HTTP while the page is HTTPS, check ASSET_URL or your Vite/build pipeline—not every local setup needs it, but CDNs and subdomains often do.
2. HTTPS and reverse proxies (Cloudflare, Nginx)
Behind a reverse proxy, Laravel may “think” the request is HTTP unless you trust forwarding headers. That yields mixed content, wrong redirects, or broken sessions. Use Laravel’s TrustProxies middleware appropriately for your deployment, and terminate TLS at the proxy as your team standardizes.
If you force HTTPS at the edge, ensure application-generated links use https consistently (config + proxy trust), not hard-coded http://127.0.0.1:8000 from an old .env.
3. Queues, scheduler, and long jobs
Locally you might run queue:work in a terminal and forget about it. In production, mail, webhooks, and exports typically need a supervisor or platform worker so ShouldQueue jobs actually run. Same for schedule:run via cron—without it, “it worked when I triggered it manually” locally never happens on the server.
Also check PHP and web server timeouts heavy uploads or reports; the dev server often masks that because you test small payloads.
4. File storage, permissions, and SQLite gotchas
Your app may write to storage/, caches, logs, or a SQLite file. The Unix user running PHP-FPM must own or be allowed to write those paths—otherwise you see 500s that never appeared locally if you ran everything as your login user.
For SQLite specifically, both the database file and its directory must be writable so the engine can create WAL/SHM sidecar files. “Read-only database” errors are almost always permissions or a read-only mount, not Laravel core.
Run php artisan storage:link where missing so public disk URLs resolve like they do on your laptop after a fresh clone.
5. Caching and config in real deployments
After you change .env in production, rebuild caches your team relies on: config:cache, route:cache, and view:cache when applicable. Stale cached config is a classic “I changed the variable but nothing changed” issue—less visible when you hot-reload everything locally without caching.
Quick sanity checklist before you open a ticket
APP_DEBUG=false,APP_URLmatches the live site.- Proxy / HTTPS trust matches your hosting stack.
- Queue worker + scheduler running if you use them.
- Writable
storage/, logs, and DB paths for the PHP user. - Config/route cache refreshed after env or route changes.
Closing
Treat “local vs production” as a set of documented differences you verify on every deploy. Once this checklist is boring, most “ghost” bugs disappear—and your teammates stop blaming PHP version Luck.