Black Friday: 40% off for life · BLACKFRIDAY40Claim →
crabsmith Get started
Browse documentation
← All documentation

Laravel

On this page

Run Laravel on PHP-FPM behind Caddy with automatic HTTPS, Vite asset builds, queue workers, and the scheduler.

Required services

On your server's Services tab, install Caddy and PHP (8.4 by default). Add MySQL or PostgreSQL if you aren't using SQLite, Redis for cache or queues, and Node.js if you build Vite assets during deploy.

Create the site

  1. Open your server's Sites tab, click New site, and choose Laravel.
  2. Enter your domain (or Free domain) and pick your repository and branch.
    • If your app needs MySQL/PostgreSQL credentials in .env before running php artisan migrate, uncheck Deploy after creating.
    • On the Run step, you can optionally turn on the Queue worker daemon and Scheduler cron job right away (or add them later under Processes).
  3. Click Create site.

On the first deploy, Crabsmith copies .env.example to .env, generates APP_KEY if empty, and sets APP_URL to your site's URL. The default Laravel deploy script handles dependencies, Vite assets, migrations, caching, and PHP-FPM reload:

sh
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
if [ -f package.json ] && command -v npm >/dev/null; then npm ci && npm run build; fi
php artisan migrate --force
php artisan optimize
sudo systemctl reload "$PHP_FPM"

If you build Vite assets on the server, commit package-lock.json so npm ci works reliably. If your app serves uploaded files from storage/app/public, run php artisan storage:link once in the site's Commands tab (or add it to your deploy script).

Configure .env

Open the site's Environment tab, set your production values, and click Save:

ini
APP_ENV=production
APP_DEBUG=false
APP_URL=https://example.com

If you use MySQL or PostgreSQL, create the database on your server's Databases tab first and copy the credentials:

ini
# MySQL (for PostgreSQL, use DB_CONNECTION=pgsql and DB_PORT=5432)
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=example
DB_USERNAME=example
DB_PASSWORD=your-database-password

Note

Because php artisan optimize caches your config, click Deploy now after editing .env so Laravel picks up the new values.

Queue worker

If you didn't enable it during site creation:

  1. Open the site's Processes tab and click New daemon.
  2. Name it queue and set the command to php artisan queue:work --tries=3 --max-time=3600 (or php artisan horizon if you use Horizon).
  3. Add php artisan queue:restart (or php artisan horizon:terminate) to the end of your deploy script (Settings → Deployment) so every deploy reloads workers with your new code.

Scheduler

If you didn't enable it during site creation:

  1. Open the site's Processes tab and click New schedule.
  2. Name it scheduler, set the cron expression to * * * * *, and set the command to php artisan schedule:run.

Verify

Open your site in a browser. Check worker output anytime under Processes → Logs, run one-off Artisan commands under Commands, and inspect deploy output under Deployments.