Deploy a Laravel app from GitHub

Get a Laravel app live with the right environment, a working database connection and a safe way to run migrations.

A stepped sculpture of stacked cream and terracotta slabs

Laravel runs happily on a modern app platform, but a few framework habits need adjusting. There is no .env file on the server, the app sits behind a proxy that handles HTTPS, logs must go somewhere you can read them, and migrations need a deliberate place to run.

This tutorial is for developers with a Laravel app in a GitHub repository who want it running in production on Launchpad. You will set the right variables, connect PostgreSQL (MySQL works the same way), decide how migrations run, and see where a Dockerfile gives you more control.

The examples assume Laravel 11 or later and PHP 8.3.

How Launchpad builds a Laravel app

Laravel apps deploy from GitHub only. Zip uploads don't support PHP projects, so push your code to a repository first.

When Launchpad finds composer.json with laravel/framework in its requirements, it:

  • Installs dependencies with composer install --no-dev --optimize-autoloader.
  • Takes the PHP version from the php requirement in composer.json (for example "php": "^8.3"), and assumes 8.3 if there is none.
  • Serves the app on port 80.
  • Pre-fills the app's variables from your .env.example.

If the repository also contains a Dockerfile, the Dockerfile wins and Launchpad builds that instead. More on that below.

The variables Laravel needs

Laravel reads its settings from environment variables, so everything that would be in .env goes under the app's Variables tab. Laravel's default .env.example is written for local development (it sets DB_CONNECTION=sqlite, for example), so review the pre-filled values rather than accepting them.

VariableValueWhy
APP_KEYOutput of php artisan key:generate --showEncrypts cookies and sessions; Laravel refuses to run without it
APP_ENVproductionTurns on production behaviour
APP_DEBUGfalseHides error details from visitors
APP_URLhttps:// plus your app's addressUsed for generated links and emails
LOG_CHANNELstderrSends logs to the platform's log view
DB_CONNECTIONpgsql or mysqlPicks the database connection

Generate the key on your own machine and paste it in:

Terminal
php artisan key:generate --show

Keep the same key for the life of the app. Changing it logs everyone out and makes previously encrypted data unreadable.

Connecting the database

Connecting a Launchpad database to the app adds its connection string as DATABASE_URL. Laravel 11 and later read a connection string from DB_URL instead, so map one to the other in config/database.php. In both the pgsql and mysql entries, change the url line:

PHP
'url' => env('DB_URL', env('DATABASE_URL')),

DB_URL still wins if you set it, and the platform's value is used otherwise. Laravel understands postgres://, postgresql:// and mysql:// schemes, so the string needs no editing. You could paste the connection string into a DB_URL variable instead, but then it won't follow the database if its details change.

Trusting the proxy

HTTPS ends at the platform's proxy, so Laravel sees plain HTTP unless you trust the forwarded headers. Without this, asset URLs and redirects use http:// and browsers block them as mixed content. In bootstrap/app.php:

PHP
->withMiddleware(function (Middleware $middleware) {
    $middleware->trustProxies(at: '*');
})

Step by step: first deploy

  1. Make the two code changes above, commit and push.
  2. In Launchpad, choose Deploy from GitHub, connect the repository and open Step-by-step setup.
  3. Check that Laravel and your PHP version were detected. Set the Health check path to /up, the health route Laravel 11 and later include by default.
  4. Fill in the variables from the table. Leave DATABASE_URL alone; it is added in the next step.
  5. Deploy. Then open the Databases tab, choose New database, pick PostgreSQL and keep Connect it to this app ticked.
  6. Press Redeploy now and run your migrations as described next.

If your front end uses Vite, public/build must exist in the running app. Add a build command such as npm ci && npm run build under Settings → Build and run and check the build log. If that doesn't suit your project, build the assets in a Dockerfile, as shown below.

Running migrations safely

Be careful here, because the obvious shortcuts cause trouble:

  • Not from your laptop. The DATABASE_URL points at the database over your project's private network, which your machine can't reach.
  • Not in a Composer hook. Hooks such as post-install-cmd run during the build, before the app is running and before its database variables are available.
  • There is no separate release step. Launchpad does not have a field for a one-off command that runs once per deploy.

The dependable approach is a start script that migrates and then starts the server, switched on by a variable. That needs control of the start command, which is what a Dockerfile gives you. Launchpad runs one instance of your app, so two containers won't race to migrate.

If a migration fails, the new version never passes its health check and the previous version keeps running. Because the old version serves traffic while the new one migrates, keep migrations backwards compatible: add columns first, remove them in a later release.

Step by step: a production Dockerfile

  1. Create docker/start.sh:
Terminal
#!/bin/sh
set -e

if [ "$RUN_MIGRATIONS" = "true" ]; then
  php artisan migrate --force
fi

php artisan optimize
chown -R www-data:www-data storage bootstrap/cache

exec apache2-foreground
  1. Create Dockerfile at the top of the repository. Remove the assets stage and its COPY line if you don't use Vite:
Dockerfile
FROM node:22-slim AS assets
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM php:8.3-apache
RUN apt-get update \
 && apt-get install -y --no-install-recommends curl git unzip libpq-dev libzip-dev \
 && docker-php-ext-install pdo_pgsql pdo_mysql zip opcache \
 && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
 && sed -ri 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
 && a2enmod rewrite

WORKDIR /var/www/html
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-interaction
COPY . .
COPY --from=assets /app/public/build ./public/build
RUN composer dump-autoload --optimize --no-dev \
 && chown -R www-data:www-data storage bootstrap/cache \
 && chmod +x docker/start.sh

EXPOSE 80
CMD ["/var/www/html/docker/start.sh"]
  1. Add a .dockerignore so local files stay out of the image:
Text
.env
.git
node_modules
vendor
storage/logs/*
  1. Add RUN_MIGRATIONS with the value true under Variables, commit and push.

EXPOSE 80 tells Launchpad the port. curl is installed because Launchpad checks health from inside the container. php artisan optimize caches config, routes and views at start-up, when the variables are available. After caching, env() only works inside config files, which is Laravel's normal production rule.

Queues and the scheduler

Launchpad has no cron scheduler, and each app runs a single start command, so plan for this:

  • Small apps: set QUEUE_CONNECTION=sync so jobs run during the request. Simple, but slow jobs slow the response.
  • With the Dockerfile: start a worker and the scheduler in the background in start.sh, before the exec line: php artisan queue:work --tries=3 & and php artisan schedule:work &. Nothing restarts them if they crash until the next deploy, so keep jobs short and watch the logs.
  • Heavier workloads: run workers on a separate server, or move timed tasks to an external scheduler that calls a protected endpoint.

Common mistakes

  • APP_DEBUG=true in production. Error pages expose configuration. Fix: set it to false.
  • Missing APP_KEY. Every page fails. Fix: generate one and add it under Variables.
  • DB_CONNECTION=sqlite left from .env.example. Data goes to a file that disappears on redeploy. Fix: set pgsql or mysql.
  • Logs written to storage/logs. You never see them. Fix: LOG_CHANNEL=stderr.
  • User uploads in storage/app. They are lost on redeploy. Fix: use S3-compatible storage, or a disk rooted in the app's /data folder, which is kept across deploys and backed up daily.

Security notes

  • Never commit .env. Variables on Launchpad are stored encrypted and never written to logs.
  • Treat APP_KEY like a password. Anyone with it can forge encrypted cookies.
  • Run composer audit regularly and keep Laravel on a supported release.
  • Only trust all proxies (at: '*') when the app is reachable solely through the platform's proxy, as it is on Launchpad.

Troubleshooting

SymptomCauseFix
"No application encryption key has been specified"APP_KEY missingGenerate it and Redeploy now
Deploy fails the health checkPath redirects or returns an errorUse /up; check the app logs
Styles missing, mixed-content warningsProxy not trusted, or APP_URL uses httpAdd trustProxies; use an https APP_URL
could not find driverPHP extension for your database missingUse the Dockerfile above, or require ext-pdo_pgsql in composer.json
relation "sessions" does not existMigrations not runSet RUN_MIGRATIONS=true and redeploy

Frequently asked questions

Can I upload a zip of my Laravel app instead?

No. Zip uploads support static sites, Node apps and Python apps. Laravel and other PHP apps deploy from GitHub.

Do I need the Dockerfile?

Not to get started. The automatic build serves a Laravel app without one. Add it when you want migrations on deploy, background workers or specific PHP extensions.

Does this work with MySQL?

Yes. Create a MySQL database instead, set DB_CONNECTION=mysql, and make sure the mysql entry in config/database.php has the same url line.

Which PHP version runs my app?

With the automatic build, the version in your composer.json php requirement. With the Dockerfile, the base image you choose (php:8.3-apache above).

Next steps

Your Laravel app now has production settings, a database connection that follows the platform, and a deliberate way to migrate. The next job is usually a custom domain and an automated test run before each push.

Share this articleLinkedIn (opens in a new tab)X (opens in a new tab)Facebook (opens in a new tab)
Was this article helpful?

Get new guides in your inbox.

One email a month. Unsubscribe anytime.