Docs Getting started
Install without Docker
Install Snapsbrew on a server with PHP, Node, MySQL, Redis and a renderer.
This page installs Snapsbrew on a Linux server without Docker. For a test on your own computer, read Development setup instead.
Requirements
| Part | Version and notes |
|---|---|
| PHP | 8.3 or later (composer.json requires ^8.3). The Docker image uses PHP 8.4. |
| PHP extensions | gd, intl, exif and bcmath (the Docker image adds these). Also pdo_mysql and redis, because REDIS_CLIENT defaults to phpredis. |
| Composer | 2.x. |
| Node | 22, to build the front-end assets. Browsershot also needs Node at render time. |
| Database | MySQL 8. The Docker stack uses MySQL 8.4. |
| Redis | For the cache, the sessions and the queues. The Docker stack uses Redis 8. |
| Web server | NGINX or Apache with PHP-FPM. The document root is the public folder. |
| Renderer | A Browserless service, or a local Chrome for Browsershot. Read Rendering. |
Install the code
-
Clone the repository into the folder that the web server serves from, for example
/var/www/snapsbrew. -
Install the PHP packages:
composer install --no-dev --optimize-autoloader -
Install the Node packages and build the assets:
npm ci npm run build -
Copy the settings file:
cp .env.example .env -
Make the app key:
php artisan key:generate
Edit .env
.env.example is for local development. Change these values for a server:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://snapsbrew.example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=snapsbrew
DB_USERNAME=snapsbrew
DB_PASSWORD=<a strong password>
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis
RENDER_DRIVER=browserless
BROWSERLESS_URL=http://127.0.0.1:3000
BROWSERLESS_TOKEN=<the Browserless token>
If a reverse proxy terminates TLS in front of the app, also set TRUSTED_PROXIES=*. Read Configuration for every variable.
Prepare the database and the instance
-
Create an empty MySQL database and a user for it.
-
Run the migrations:
php artisan migrate --force -
Create the Passport keys and the storage link:
php artisan snapsbrew:install --prepare -
Cache the configuration, the routes and the views:
php artisan config:cache php artisan route:cache php artisan view:cache -
Make sure that the web server user can write to
storageandbootstrap/cache.
The migrations also add the six starter templates. A new user can copy them from /templates/new.
Start the background processes
Snapsbrew needs two long-running processes next to the web server:
- The queue worker:
php artisan horizon. Read Queues and Horizon. - The scheduler. Read Scheduler.
Use a process manager, for example systemd or Supervisor, to keep Horizon running. The repository ships no unit file for this. This is an example for systemd:
[Unit]
Description=Snapsbrew Horizon
After=network.target
[Service]
User=www-data
WorkingDirectory=/var/www/snapsbrew
ExecStart=/usr/bin/php artisan horizon
Restart=always
[Install]
WantedBy=multi-user.target
Start the renderer
For a server, Browserless is the recommended renderer. The repository has a Compose file for it in deploy/browserless/:
export BROWSERLESS_TOKEN=$(openssl rand -hex 24)
docker compose -f deploy/browserless/docker-compose.yml up -d
This Compose file binds the port to 127.0.0.1:3000 only. Put the same token in BROWSERLESS_TOKEN of the app.
If you do not use Docker at all, set RENDER_DRIVER=browsershot and install Chrome on the server. Read Rendering.
Create the owner account
-
Show the setup URL:
php artisan snapsbrew:setup-url -
Open the URL in a browser.
-
Fill in the form to create the owner account.
To create the owner in the terminal instead, run php artisan snapsbrew:install without --prepare.
Make sure that the instance works
GET /upreturns 200 when the app runs.- Open
/horizonas the owner. The dashboard shows the queue worker. - Render a test snap. Read Your first snap.