Installation — VPS with Docker
Traffic Exchange Script ships with a complete Docker setup — a Dockerfile for the application container and a docker-compose.yml that spins up the full stack (app, Nginx, MySQL, Redis, and a local mail catcher). This is the recommended approach for VPS deployments.
What’s Included
| File | Purpose |
|---|---|
Dockerfile |
Builds the PHP 8.3-FPM application image with all required extensions |
docker-compose.yml |
Defines the full stack: app, web (Nginx), db (MySQL 8), redis, mailpit |
docker/nginx/default.conf |
Nginx configuration for the web container |
Services in docker-compose.yml
| Service | Image | Description |
|---|---|---|
app |
Built from Dockerfile |
PHP 8.3-FPM application |
web |
nginx:1.27-alpine |
Nginx web server, exposes port 80 |
db |
mysql:8.0 |
MySQL database |
redis |
redis:7-alpine |
Redis for cache, queues, sessions |
mailpit |
axllent/mailpit |
Local email catcher for development (port 8025) |
Quick Start (Development)
# Clone or upload the script to your server
cd /path/to/traffic-exchange-script
# Copy and configure the environment file
cp .env.example .env
nano .env # Fill in APP_KEY, DB_*, TE_LICENSE_KEY, etc.
# Build and start the containers
docker compose up -d --build
# Generate the app key
docker compose exec app php artisan key:generate
# Run migrations and seed
docker compose exec app php artisan migrate --seed
# Create the storage symlink
docker compose exec app php artisan storage:link
Your site will be available at http://localhost (or your server’s IP on port 80).
Environment Variables for Docker
The docker-compose.yml passes several variables from your .env to the containers. When using Docker, set these in .env:
APP_PORT=80 # Host port for the Nginx web container
DB_DATABASE=traffic_exchange
DB_USERNAME=te_user
DB_PASSWORD=secret
DB_ROOT_PASSWORD=rootsecret
REDIS_PORT=6379
MAILPIT_PORT=8025
# DB and Redis host names match service names in docker-compose.yml
DB_HOST=db
REDIS_HOST=redis
# Queue and cache use Redis in VPS mode
QUEUE_CONNECTION=redis
CACHE_STORE=redis
SESSION_DRIVER=redis
TE_HOSTING_MODE=vps
Running Queue Workers in Docker
The docker-compose.yml does not include a dedicated queue worker container by default. You have two options:
Option A — Add a worker service to docker-compose.yml:
worker:
build:
context: .
dockerfile: Dockerfile
container_name: te_worker
restart: unless-stopped
working_dir: /var/www/html
volumes:
- .:/var/www/html
- /var/www/html/vendor
command: php artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
depends_on:
- db
- redis
networks:
- te_network
Option B — Run the worker directly in the app container:
docker compose exec -d app php artisan queue:work redis --sleep=3 --tries=3
Scheduler in Docker
Add a cron job on the host system (not inside the container) to run the Laravel scheduler:
crontab -e
* * * * * docker exec te_app php artisan schedule:run >> /dev/null 2>&1
Replace te_app with your app container name if it differs.
Production Deployment on VPS
For production, extend this setup with:
-
SSL termination — Run Nginx (or Traefik/Caddy) on the host in front of the Docker Nginx container, or mount SSL certificates into the web container. Let’s Encrypt via Certbot works well on the host.
-
Reverb WebSocket — Add a Reverb service or run it inside the app container:
bash docker compose exec -d app php artisan reverb:start --host=0.0.0.0 --port=8080 -
Persistent volumes — The
docker-compose.ymlalready defines named volumes (te_db_data,te_redis_data). Ensure these are backed up regularly. Also mount./storageas a volume to persist uploaded files. -
Remove Mailpit — In production, remove the
mailpitservice and configure real SMTP credentials in.env. -
Health checks — The MySQL service has a built-in health check. The
appservice starts only afterdbis healthy.
PHP Extensions Included in the Dockerfile
The Dockerfile installs these extensions:
| Extension | Purpose |
|---|---|
bcmath |
Arbitrary precision math |
exif |
Image metadata |
gd |
Image processing |
intl |
Internationalisation |
mbstring |
Multi-byte string handling |
pdo_mysql |
MySQL database driver |
zip |
Archive support |
redis (PECL) |
Redis client |
If you require additional extensions, add them to the Dockerfile‘s docker-php-ext-install block and rebuild.
Useful Docker Commands
# View running containers
docker compose ps
# View application logs
docker compose logs -f app
# Run an artisan command
docker compose exec app php artisan {command}
# Access the database
docker compose exec db mysql -u te_user -p traffic_exchange
# Rebuild after code changes
docker compose up -d --build
# Stop all containers
docker compose down
# Stop and remove volumes (DESTROYS DATA)
docker compose down -v
Traditional VPS (Without Docker)
If you prefer a traditional setup without Docker, follow the VPS Installation guide. Docker is recommended but not required — the script runs on any standard PHP 8.3 + Nginx/Apache + MySQL stack.


Screenshots
