Deployment
Production .env
Edit it with sudo nano /srv/myapp/.env:
APP_NAME="My App"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://app.example.com
APP_KEY=
SERVER_HOST=127.0.0.1
SERVER_PORT=8000
TRUSTED_PROXIES=127.0.0.1
SHUTDOWN_TIMEOUT=30
LOG_LEVEL=info
LOG_FILE=storage/logs/smeltery.log
DATABASE_URL=sqlite://database/database.sqlite?mode=rwc
SESSION_DRIVER=database
SESSION_LIFETIME=120
CACHE_STORE=database
STATIC_CACHE_CONTROL=no-cache
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_ENCRYPTION=starttls
MAIL_USERNAME=postmaster@example.com
MAIL_PASSWORD="the SMTP password"
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME="My App"
WATCHFIRE_DASHBOARD=auth
Then the key: print a new one and paste it after APP_KEY=:
cd /srv/myapp && ./myapp key:generate --show
--show only prints a fresh key: it reads no .env and writes nothing, so any user can run it. (sudo ./myapp
key:generate without --show writes the key into .env itself and keeps the file's owner, group and mode; with
APP_ENV=production (or without APP_ENV) it does so only while APP_KEY is empty, unless --force is given.)
| Key | Production value | Why |
|---|---|---|
APP_ENV |
production |
migrate, migrate:rollback, migrate:fresh and db:seed refuse to run without --force; key:generate keeps an existing key; the seeder of new apps creates no demo user; the log mailer withholds mail bodies; reset links never reach the log; the Watchfire dashboard is never open without signing in |
APP_DEBUG |
false |
error pages show no internal details (new apps' .env has true) |
APP_URL |
https://app.example.com |
https turns on the session cookie's Secure flag; password-reset links and mail use it |
APP_KEY |
from key:generate --show |
encrypts session cookies and signs Spark state and uploads; serve refuses to start without one (at least 32 bytes) |
SERVER_HOST / SERVER_PORT |
127.0.0.1 / 8000 |
only the proxy on the same machine reaches the app |
TRUSTED_PROXIES |
127.0.0.1 |
the client IP (login throttle, auth.ip(), the request log) is read from the proxy's X-Forwarded-For; see The server |
SHUTDOWN_TIMEOUT |
30 |
seconds a stop waits for running requests and agents; the systemd unit's TimeoutStopSec is larger |
LOG_LEVEL |
info |
new apps' .env has debug, which logs every request |
LOG_FILE |
storage/logs/smeltery.log, or empty |
stderr goes to the journal anyway; the file keeps one .1 backup at LOG_MAX_BYTES (10 MiB), so it needs no logrotate. Empty logs to the journal only |
DATABASE_URL |
see below | |
SESSION_DRIVER |
database (or file) |
a logout deletes the session on the server, so a copied session cookie stops working; database uses the sessions table of new apps. cookie stores nothing on the server: a copy of the cookie stays valid until the session expires (see Authentication) |
CACHE_STORE |
database (or redis) |
the store must span processes for Watchfire's coordination ("Several processes" in Watchfire); memory does not |
PUBSUB_DRIVER |
auto, or database / redis with several serve processes |
serve --no-agents and work share Sparks pushes through the database (with the pubsub_messages table: in new apps with Watchfire, else from smeltery pubsub:install) or Redis; several full serve processes need it set explicitly (see PubSub) |
STATIC_CACHE_CONTROL |
no-cache |
browsers revalidate public/ files with a cheap 304, so a deploy's new app.css is seen at once; public, max-age=31536000, immutable for versioned file names |
HSTS_MAX_AGE |
31536000 once HTTPS works for the domain (not set at first) |
browsers then use HTTPS only for the domain for a year; sent only with an https:// APP_URL |
MAIL_* |
MAIL_MAILER=smtp and the server's settings |
with log, mail is not sent (see Mail) |
WATCHFIRE_DASHBOARD |
auth or off |
auth: signed-in users the dashboard gate admits (below); off: no dashboard (404) |
DATABASE_URL per backend (the backend's feature must be compiled in, see Database and models):
DATABASE_URL=sqlite://database/database.sqlite?mode=rwc
DATABASE_URL=postgres://myapp:secret@127.0.0.1:5432/myapp
DATABASE_URL=mysql://myapp:secret@127.0.0.1:3306/myapp
The SQLite path is relative to the app root; its directory must exist (the file is created). SQLite runs in WAL mode,
so serve, work and migrate can use the file at the same time, on a local disk.
Further keys for processes and Watchfire: QUEUE_DRIVER (database, or redis with REDIS_URL and the redis
feature), WATCHFIRE_IN_SERVE (false: serve never runs the agents),
WATCHFIRE_API_ADDR (the API address of work, e.g. 127.0.0.1:8001), WATCHFIRE_LOCK_STORE (default
CACHE_STORE) and WATCHFIRE_LEASE_TTL (30 s); see Watchfire. Every key
of the framework is in Configuration.