Deploy Laravel

Deploy a Laravel PHP app with PostgreSQL and HTTPS in one click.

Deploy Laravel

Just deployed

/var/lib/postgresql/data

Deploy and Host Laravel on Railway

Laravel logo

Laravel is the most popular PHP framework, with 34,000+ GitHub stars on its core: routing, Eloquent ORM, queues, auth scaffolding and Blade templates. This template deploys a Laravel app with a PostgreSQL database and HTTPS on Railway in a few minutes. Heroku's always-on dyno plus database starts at $12/month — a small Laravel app on Railway typically runs for $3–8/month.


What This Template Deploys

ServicePurpose
laravelLaravel 11 app (PHP 8.2+, Vite assets) built from GitHub, public HTTPS domain. Sessions, cache and queue use the database driver.
PostgresPostgreSQL with SSL, connected through DB_URL.
Persistent VolumeMounted on Postgres at /var/lib/postgresql/data — your data survives redeploys.

Two services, built by Railpack without a Dockerfile. APP_KEY and the database password are generated at deploy time.


About Hosting Laravel

Production Laravel needs PHP-FPM or a PHP server, a web server, a database, an APP_KEY, built frontend assets, migrations and somewhere for sessions and queues. On a VPS that's Nginx, PHP-FPM, Composer, Node and Supervisor to manage.

On Railway, Railpack installs Composer and Node dependencies, builds Vite assets and serves the app, while Postgres runs alongside it. Using the database driver for sessions, cache and queues means no extra Redis service to start with.

Two settings to change before launch. APP_DEBUG is true, which shows stack traces to visitors — set it to false. And DB_URL points at Postgres's public URL; switch it to ${{Postgres.DATABASE_URL}} to keep database traffic on Railway's private network. The starter uses Laravel 11; plan an upgrade to the current major release.

Typical cost: ~$3–8/month on Railway for the app and database. Heroku's Basic dyno is $7 plus $5 for the smallest Postgres.


Deploy Laravel in Under 5 Minutes

  1. Click Deploy on Railway — Railway forks the code, builds PHP and Vite assets and starts Postgres (~3–4 minutes).
  2. Set APP_DEBUG to false and APP_URL to your public URL on the laravel service.
  3. Change DB_URL to ${{Postgres.DATABASE_URL}} for private networking.
  4. Run php artisan migrate with the Railway CLI (or add it to a pre-deploy command).
  5. Clone your repository, build features and push — Railway redeploys.

No PHP-FPM tuning. No Nginx config. No server to patch.


Common Use Cases

  • Laravel Forge or Heroku alternative — "deploy laravel app" without managing servers
  • SaaS and web apps — Eloquent, auth and queues on a real database
  • REST APIs — Laravel Sanctum-backed APIs for mobile or SPA frontends
  • Admin panels — add Filament or Nova
  • E-commerce and CMS builds — Laravel-based platforms on managed Postgres
  • Learning and prototypes — a live Laravel app in minutes

Configuration

VariableRequiredDescription
APP_KEY🔐 Auto-generatedLaravel encryption key. Never change it once users have sessions or encrypted data.
APP_DEBUG✅ Changetrue by default — set false in production.
APP_URLRecommendedYour public URL, used for links and asset URLs.
DB_URL✅ Auto-injectedPostgres connection. Switch to the private DATABASE_URL.
SESSION_DRIVER, CACHE_STORE, QUEUE_CONNECTIONOptionaldatabase by default; move to Redis as traffic grows.
MAIL_MAILEROptionallog by default — configure a mail provider to send real email.

APP_DEBUG=true exposes secrets. Laravel's debug error pages can reveal environment details; turn debug off before sharing the URL.


Laravel on Railway vs. Alternatives

Laravel on RailwayHerokuRenderShared PHP hosting
Monthly cost (app + database)~$3–8 usage$7 Basic + $5 PostgresFree tier sleeps; paid plus databaseLow, varies
Managed Postgres in the same project✅ Included✅ Add-on⚠️ Free DB expires in 30 days⚠️ Usually MySQL only
Always-on app✅ Yes✅ On Basic⚠️ Free spins down✅ Yes
Queues and workers✅ Extra service✅ Worker dyno✅ Background worker❌ Rarely supported
Deploy on git push✅ Yes✅ Yes✅ Yes❌ FTP or manual
License✅ MIT Laravel, starter code yours❌ Proprietary platform❌ Proprietary platform❌ Proprietary platform

Dependencies for Laravel Hosting

  • Railway account — Hobby ($5/month) covers a small app and database.
  • A GitHub account — Railway forks the starter so you own the code.
  • A mail provider (Postmark, Mailgun, SES) when you need real email.

Deployment Dependencies

Implementation Details

Railpack detects composer.json and package.json, installs PHP and Node dependencies, builds assets with Vite and serves the app. Laravel connects to Postgres through DB_URL (DB_CONNECTION=pgsql), and the database driver backs sessions, cache and the queue.

Production checklist: APP_DEBUG=false, APP_URL set, DB_URL on the private network, migrations run on deploy, a real MAIL_MAILER, and an upgrade from Laravel 11 to a supported release.


Frequently Asked Questions

What does this Laravel template include? A Laravel 11 application with Vite-built assets and a PostgreSQL database, using the database driver for sessions, cache and queues, on a public HTTPS URL.

How much does Laravel hosting cost compared to Heroku? About $3–8/month in Railway usage for the app and database. Heroku is $7 for a Basic dyno plus $5 for its smallest Postgres.

Why does Laravel show a 500 error or "No application encryption key"? APP_KEY must be set — this template generates it. For other 500s, check the deploy logs; with APP_DEBUG=false details go to the log instead of the page.

Do I lose data when I redeploy? No. Data lives in Postgres on a persistent volume. Files stored on the local disk reset on deploy — use a volume or S3 for uploads.

How do I run migrations and queue workers? Run php artisan migrate through the Railway CLI or a pre-deploy command, and add a second service from the same repo running php artisan queue:work.

Is this starter production-ready? Almost: turn APP_DEBUG off, use the private database URL, configure mail, and plan an upgrade from Laravel 11, whose security support has ended.


Why Deploy and Host Laravel on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Laravel on Railway, you get a Laravel app and PostgreSQL with git-push deploys for a few dollars a month, without managing PHP servers.


Template Content

More templates in this category

View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
5
View Template
NEW
Next.js + Prisma + PostgreSQL Starter
Deploy a Next.js app with Prisma ORM and PostgreSQL in one click.

blueorange
0
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5