Laravel Supervisor

Config Generator

Generate production-ready supervisor configuration files for Laravel queue workers, Horizon, and custom processes. No registration required, completely free, and optimized for Laravel 12.

Laravel Supervisor Config Generator

Create up to 10 supervisor configuration files for your Laravel application

Configuration Generated Successfully!

Your supervisor configuration files are ready. Copy each config to /etc/supervisor/conf.d/ and run sudo supervisorctl reread && sudo supervisorctl update

Stack Toast Logo

Stack Toast

Laravel Boilerplate

Launch Your SaaS in Days, Not Months

The first Laravel boilerplate built for vibe coding. 200+ pre-built features, multiple payment processors, and Cursor-optimized code.

Laravel 12 Ready
Cursor Optimized
Launch in Days
No Setup Hassles

Everything You Need

200+ Ready Features
Pre-built & tested
100+ AI Models
Integrated & ready
4 Payment Gateways
Stripe, Paddle, Lemon Squeezy, Coinbase
0 Headaches
Just start building

Complete Guide to Laravel Supervisor Configuration

Laravel Supervisor configuration is essential for production environments where you need reliable process management for queue workers, Horizon, and custom processes. This comprehensive guide covers everything you need to know about setting up, configuring, and managing Laravel 12 applications with Supervisor in production environments.

1. What is Supervisor?

Supervisor is a client/server system that allows users to monitor and control a number of processes on UNIX-like operating systems. It provides a unified interface for managing long-running processes, making it ideal for Laravel applications that need to run queue workers, Horizon, and other background processes reliably in production environments.

Supervisor operates as a process control system that monitors and manages Laravel processes. When you configure Supervisor for Laravel, it creates a persistent connection to your queue workers, Horizon processes, and custom commands, ensuring they remain running even after system restarts or process failures.

2. Why Use Supervisor with Laravel?

  • Process Reliability: Automatically restart failed processes and maintain uptime
  • Queue Management: Keep Laravel queue workers running continuously
  • Horizon Support: Manage Laravel Horizon processes for Redis-based queues
  • Log Management: Centralized logging and monitoring of all processes
  • Resource Control: Limit memory usage and prevent runaway processes
  • Production Ready: Battle-tested solution used by thousands of Laravel applications
  • Zero Downtime: Graceful process restarts without service interruption
  • Scalability: Easy horizontal scaling of queue workers

3. Laravel 12 Queue System Overview

Laravel 12 introduces significant improvements to the queue system, making it more efficient and reliable for production environments. The queue system provides a unified API across various backends including Redis, Amazon SQS, database, and Beanstalkd.

Key Laravel 12 queue features that work seamlessly with Supervisor:

  • Enhanced Job Batching: Improved batch processing with better error handling
  • Job Middleware: Advanced middleware for rate limiting and job overlap prevention
  • Queue Priorities: Better priority handling for different job types
  • Improved Monitoring: Enhanced queue monitoring and debugging capabilities
  • Better Error Handling: More robust error handling and retry mechanisms

4. Supervisor Installation & Setup

Installing Supervisor is straightforward on most Linux distributions. Here are the installation commands for popular systems:

Ubuntu/Debian Installation

# Update package list
sudo apt update

# Install Supervisor
sudo apt install supervisor

# Enable and start Supervisor service
sudo systemctl enable supervisor
sudo systemctl start supervisor

# Check Supervisor status
sudo systemctl status supervisor

CentOS/RHEL Installation

# Install EPEL repository (if not already installed)
sudo yum install epel-release

# Install Supervisor
sudo yum install supervisor

# Enable and start Supervisor service
sudo systemctl enable supervisord
sudo systemctl start supervisord

# Check Supervisor status
sudo systemctl status supervisord

macOS Installation (using Homebrew)

# Install Supervisor
brew install supervisor

# Start Supervisor service
brew services start supervisor

# Check Supervisor status
brew services list | grep supervisor

5. Basic Supervisor Configuration

Supervisor configuration files are typically stored in /etc/supervisor/conf.d/ on Linux systems. Each configuration file should have a .conf extension and define one or more programs to manage.

Basic Configuration Structure

[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=1
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

6. Laravel Queue Workers Configuration

Laravel queue workers are the backbone of background job processing. Here are the most common configurations for Ubuntu servers:

Basic Queue Worker Configuration

[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

High-Performance Queue Worker (Multiple Processes)

[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600 --memory=512
directory=/var/www/your-app
user=www-data
numprocs=4
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

Priority Queue Worker Configuration

[program:laravel-high-priority-worker]
command=php /var/www/your-app/artisan queue:work high --sleep=1 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-high-priority-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-high-priority-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

[program:laravel-default-worker]
command=php /var/www/your-app/artisan queue:work default --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-default-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-default-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

7. Laravel Horizon Configuration

Laravel Horizon provides a beautiful dashboard and configuration system for Redis-powered queues. Here's how to configure it with Supervisor on Ubuntu:

Horizon Installation Commands

# Install Horizon via Composer
composer require laravel/horizon

# Publish Horizon configuration
php artisan horizon:install

# Publish Horizon assets
php artisan horizon:publish

Horizon Supervisor Configuration

[program:laravel-horizon]
command=php /var/www/your-app/artisan horizon
directory=/var/www/your-app
user=www-data
numprocs=1
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-horizon.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-horizon-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

Horizon Configuration File (config/horizon.php)

 [
        'production' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default'],
                'balance' => 'simple',
                'processes' => 3,
                'tries' => 3,
                'nice' => 0,
            ],
            'supervisor-2' => [
                'connection' => 'redis',
                'queue' => ['high'],
                'balance' => 'simple',
                'processes' => 2,
                'tries' => 3,
                'nice' => 0,
            ],
        ],
    ],
];

8. Custom Processes & Commands

Supervisor can manage custom Laravel artisan commands and other processes. Here are common configurations for Ubuntu:

Laravel Scheduler Configuration

[program:laravel-scheduler]
command=php /var/www/your-app/artisan schedule:work
directory=/var/www/your-app
user=www-data
numprocs=1
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-scheduler.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-scheduler-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production

Custom Artisan Command

[program:laravel-data-processor]
command=php /var/www/your-app/artisan data:process --daemon
directory=/var/www/your-app
user=www-data
numprocs=1
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-data-processor.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-data-processor-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production

WebSocket Server (Laravel Reverb)

[program:laravel-reverb]
command=php /var/www/your-app/artisan reverb:start --host=0.0.0.0 --port=8080
directory=/var/www/your-app
user=www-data
numprocs=1
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-reverb.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-reverb-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production

9. Environment Variables & Security

Proper environment variable configuration is crucial for security and functionality. Here are the essential variables for Laravel 12:

Essential Environment Variables

# Basic Laravel Configuration
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com

# Database Configuration
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password

# Queue Configuration
QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

# Cache Configuration
CACHE_DRIVER=redis
SESSION_DRIVER=redis

# Mail Configuration
MAIL_MAILER=smtp
MAIL_HOST=your-smtp-host
MAIL_PORT=587
MAIL_USERNAME=your-email
MAIL_PASSWORD=your-password
MAIL_ENCRYPTION=tls

Security Best Practices

  • File Permissions: Ensure configuration files have proper permissions (644 for files, 755 for directories)
  • User Isolation: Run processes as non-root user (www-data)
  • Log Rotation: Configure log rotation to prevent disk space issues
  • Environment Separation: Use different configurations for staging and production
  • Secret Management: Store sensitive data in environment variables, not in config files

10. Monitoring & Management

Effective monitoring and management of Supervisor processes is essential for production environments. Here are the key commands and techniques:

Supervisor Management Commands

# Check Supervisor status
sudo supervisorctl status

# Start all processes
sudo supervisorctl start all

# Stop all processes
sudo supervisorctl stop all

# Restart all processes
sudo supervisorctl restart all

# Restart specific process
sudo supervisorctl restart laravel-worker

# Reload configuration
sudo supervisorctl reread
sudo supervisorctl update

# View process logs
sudo supervisorctl tail laravel-worker

# Follow logs in real-time
sudo supervisorctl tail -f laravel-worker

# Clear logs
sudo supervisorctl clear laravel-worker

System Service Management

# Check Supervisor service status
sudo systemctl status supervisor

# Start Supervisor service
sudo systemctl start supervisor

# Stop Supervisor service
sudo systemctl stop supervisor

# Restart Supervisor service
sudo systemctl restart supervisor

# Enable Supervisor on boot
sudo systemctl enable supervisor

# Disable Supervisor on boot
sudo systemctl disable supervisor

11. Digital Ocean Setup Guide

Digital Ocean is one of the most popular cloud providers for Laravel applications. Here's a complete guide to setting up Laravel with Supervisor on Digital Ocean droplets.

Creating a Digital Ocean Droplet

Start by creating a new droplet with the following specifications:

  • Image: Ubuntu 22.04 LTS (recommended for Laravel 12)
  • Size: At least 2GB RAM for production Laravel applications
  • Region: Choose closest to your target audience
  • Authentication: SSH keys (more secure than passwords)

Initial Server Setup

# Connect to your droplet
ssh root@your-droplet-ip

# Update system packages
apt update && apt upgrade -y

# Create a non-root user
adduser laravel
usermod -aG sudo laravel

# Switch to the new user
su - laravel

# Generate SSH key for the user (optional)
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"

Install LAMP Stack

# Install Apache, MySQL, PHP, and required extensions
sudo apt install -y apache2 mysql-server php8.2 php8.2-cli php8.2-fpm php8.2-mysql php8.2-xml php8.2-gd php8.2-curl php8.2-mbstring php8.2-zip php8.2-bcmath php8.2-intl php8.2-redis

# Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

# Install Node.js and NPM
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install Redis
sudo apt install -y redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server

Install Supervisor on Digital Ocean

# Install Supervisor
sudo apt install -y supervisor

# Enable and start Supervisor
sudo systemctl enable supervisor
sudo systemctl start supervisor

# Check Supervisor status
sudo systemctl status supervisor

Deploy Laravel Application

# Create application directory
sudo mkdir -p /var/www/your-app
sudo chown -R laravel:laravel /var/www/your-app

# Clone your Laravel application
cd /var/www/your-app
git clone https://github.com/your-username/your-laravel-app.git .

# Install dependencies
composer install --optimize-autoloader --no-dev
npm install && npm run build

# Set up environment
cp .env.example .env
php artisan key:generate

# Set proper permissions
sudo chown -R www-data:www-data /var/www/your-app
sudo chmod -R 755 /var/www/your-app
sudo chmod -R 775 /var/www/your-app/storage
sudo chmod -R 775 /var/www/your-app/bootstrap/cache

Digital Ocean Specific Supervisor Configuration

# Create supervisor configuration for Digital Ocean
sudo nano /etc/supervisor/conf.d/laravel-worker.conf

# Add the following configuration:
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

# Reload supervisor configuration
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker

12. Hetzner Setup Guide

Hetzner Cloud offers excellent performance and competitive pricing for Laravel applications. Here's how to set up Laravel with Supervisor on Hetzner Cloud servers.

Creating a Hetzner Cloud Server

Create a new server with these recommended specifications:

  • Image: Ubuntu 22.04 (recommended for Laravel 12)
  • Type: CX21 (2 vCPU, 4GB RAM) minimum for production
  • Location: Choose based on your target audience (Nuremberg, Helsinki, or Ashburn)
  • SSH Key: Add your SSH key for secure access

Install LEMP Stack (Nginx + MySQL + PHP)

# Install Nginx
sudo apt install -y nginx

# Install MySQL
sudo apt install -y mysql-server
sudo mysql_secure_installation

# Install PHP 8.2 and extensions
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install -y php8.2-fpm php8.2-cli php8.2-mysql php8.2-xml php8.2-gd php8.2-curl php8.2-mbstring php8.2-zip php8.2-bcmath php8.2-intl php8.2-redis

# Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

# Install Redis
sudo apt install -y redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server

Hetzner Specific Supervisor Configuration

# Create supervisor configuration for Hetzner
sudo nano /etc/supervisor/conf.d/laravel-worker.conf

# Add the following configuration:
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
environment=APP_ENV=production,QUEUE_CONNECTION=redis

# Reload supervisor configuration
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker

13. Troubleshooting Common Issues

Here are solutions to the most common issues you might encounter when setting up Laravel with Supervisor:

Queue Workers Not Starting

# Check Supervisor status
sudo supervisorctl status

# Check logs for errors
sudo supervisorctl tail laravel-worker

# Check Laravel logs
tail -f /var/www/your-app/storage/logs/laravel.log

# Verify PHP path
which php

# Test artisan command manually
cd /var/www/your-app
php artisan queue:work --once

Permission Issues

# Fix file permissions
sudo chown -R www-data:www-data /var/www/your-app
sudo chmod -R 755 /var/www/your-app
sudo chmod -R 775 /var/www/your-app/storage
sudo chmod -R 775 /var/www/your-app/bootstrap/cache

# Check if user exists
id www-data

# Create user if it doesn't exist
sudo useradd -r -s /bin/false www-data

Memory Issues

# Check memory usage
free -h
ps aux --sort=-%mem | head

# Add memory limit to supervisor config
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --memory=512
# ... other settings

# Monitor memory usage
watch -n 1 'ps aux | grep queue:work'

Database Connection Issues

# Test database connection
cd /var/www/your-app
php artisan tinker
DB::connection()->getPdo();

# Check MySQL status
sudo systemctl status mysql

# Restart MySQL
sudo systemctl restart mysql

# Check MySQL logs
sudo tail -f /var/log/mysql/error.log

14. Best Practices & Production Tips

To ensure optimal performance and reliability with Laravel Supervisor, follow these proven best practices:

1. Proper Resource Limits

Set appropriate memory and CPU limits to prevent resource exhaustion and ensure system stability. Without proper limits, queue workers can consume all available memory, causing system crashes.

Memory Limits
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --memory=512 --sleep=3 --tries=3
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
environment=APP_ENV=production,QUEUE_CONNECTION=redis
Process Limits
# Monitor memory usage
watch -n 1 'ps aux --sort=-%mem | head -10'

# Set system-wide limits in /etc/security/limits.conf
www-data soft nofile 65536
www-data hard nofile 65536
www-data soft nproc 4096
www-data hard nproc 4096

Key Points: Start with 512MB memory limit per worker, monitor usage, and adjust based on your job complexity. Use --memory=512 flag to restart workers when they exceed memory limits.

2. Log Management

Configure log rotation and monitoring to prevent disk space issues. Unmanaged logs can quickly fill up your server's disk space, causing application failures.

Log Rotation Configuration
# Create logrotate configuration
sudo nano /etc/logrotate.d/supervisor

# Add the following configuration:
/var/log/supervisor/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 644 root root
    postrotate
        /usr/bin/supervisorctl reread > /dev/null 2>&1 || true
        /usr/bin/supervisorctl update > /dev/null 2>&1 || true
    endscript
}
Supervisor Log Configuration
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=5
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=5

Key Points: Set log file size limits (10MB), keep 5 backups, enable compression, and monitor disk usage with df -h and du -sh /var/log/supervisor/.

3. Environment Variables

Use environment-specific configurations for different deployment stages. This ensures proper separation between development, staging, and production environments.

Environment-Specific Configurations
# Production Configuration
[program:laravel-worker-prod]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=/var/www/your-app
user=www-data
numprocs=4
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker-prod.log
stderr_logfile=/var/log/supervisor/laravel-worker-prod-error.log
environment=APP_ENV=production,QUEUE_CONNECTION=redis,LOG_LEVEL=error

# Staging Configuration
[program:laravel-worker-staging]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=1800
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker-staging.log
stderr_logfile=/var/log/supervisor/laravel-worker-staging-error.log
environment=APP_ENV=staging,QUEUE_CONNECTION=redis,LOG_LEVEL=debug

Key Points: Use different process names, log files, and environment variables for each stage. Consider using fewer workers in staging and different log levels for debugging.

4. Process Monitoring

Implement health checks and monitoring for all managed processes. Proactive monitoring helps identify issues before they cause downtime.

Health Check Script
#!/bin/bash
# Create health check script
sudo nano /usr/local/bin/supervisor-health-check.sh

# Add the following content:
#!/bin/bash

# Check if supervisor is running
if ! systemctl is-active --quiet supervisor; then
    echo "Supervisor service is not running"
    exit 1
fi

# Check if all processes are running
FAILED_PROCESSES=$(supervisorctl status | grep -v RUNNING | grep -v STOPPED | wc -l)

if [ $FAILED_PROCESSES -gt 0 ]; then
    echo "Some processes are not running properly:"
    supervisorctl status | grep -v RUNNING
    exit 1
fi

echo "All processes are running normally"
exit 0

# Make executable
sudo chmod +x /usr/local/bin/supervisor-health-check.sh
Real-time Monitoring Commands
# Monitor process status
watch -n 1 'supervisorctl status'

# Monitor memory usage
watch -n 1 'ps aux --sort=-%mem | grep queue:work'

# Monitor log files
tail -f /var/log/supervisor/laravel-worker.log

# Check system resources
htop
iostat -x 1

Key Points: Set up automated health checks, monitor log file sizes, track memory usage, and configure alerts for process failures. Use tools like New Relic, DataDog, or simple shell scripts for monitoring.

5. Graceful Shutdowns

Configure proper signal handling for clean process termination. This ensures jobs complete properly and prevents data corruption during deployments or maintenance.

Signal Handling Configuration
[program:laravel-worker]
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --timeout=60
directory=/var/www/your-app
user=www-data
numprocs=2
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-worker.log
stderr_logfile=/var/log/supervisor/laravel-worker-error.log
stopwaitsecs=30
killasgroup=true
stopasgroup=true
environment=APP_ENV=production,QUEUE_CONNECTION=redis
Deployment Script with Graceful Shutdown
#!/bin/bash
# Deployment script with graceful shutdown
echo "Starting deployment..."

# Gracefully stop workers
echo "Stopping queue workers..."
supervisorctl stop laravel-worker

# Wait for current jobs to complete
echo "Waiting for jobs to complete..."
sleep 30

# Update application code
echo "Updating application..."
git pull origin main
composer install --no-dev --optimize-autoloader
npm run build

# Clear caches
php artisan config:cache
php artisan route:cache
php artisan view:cache

# Restart workers
echo "Starting queue workers..."
supervisorctl start laravel-worker

echo "Deployment completed successfully!"

Key Points: Use stopwaitsecs to allow time for jobs to complete, set killasgroup=true for proper signal propagation, and implement job-level shutdown checks for long-running processes.

6. Security Considerations

Run processes with appropriate user permissions and access controls. Security is crucial in production environments to prevent unauthorized access and data breaches.

User and Permission Setup
# Create dedicated user for Laravel processes
sudo useradd -r -s /bin/false -d /var/www/your-app laravel-worker
sudo usermod -aG www-data laravel-worker

# Set proper file permissions
sudo chown -R www-data:www-data /var/www/your-app
sudo chmod -R 755 /var/www/your-app
sudo chmod -R 775 /var/www/your-app/storage
sudo chmod -R 775 /var/www/your-app/bootstrap/cache

# Secure supervisor configuration files
sudo chown root:root /etc/supervisor/conf.d/*.conf
sudo chmod 644 /etc/supervisor/conf.d/*.conf
Firewall and Network Security
# Configure UFW firewall
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 'Apache Full'  # or 'Nginx Full'
sudo ufw allow 6379  # Redis (if needed externally)
sudo ufw --force enable

# Restrict supervisor access
sudo nano /etc/supervisor/supervisord.conf

# Add these security settings:
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0700
chown=root:root

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

# Disable web interface in production
# [inet_http_server]
# port=127.0.0.1:9001

Key Points: Use dedicated users with minimal privileges, secure file permissions (600 for .env, 644 for configs), configure firewalls, disable supervisor web interface in production, and never store passwords in supervisor configuration files.

15. Frequently Asked Questions

Is this Laravel Supervisor config generator free to use?

Yes, our Laravel Supervisor configuration generator is completely free to use. There are no hidden fees, subscriptions, or premium tiers. You can generate as many configuration files as you need without any restrictions.

Do I need to install Supervisor first?

Yes, you need to install Supervisor on your server before using the generated configuration files. The tool generates the configuration files, but you'll need to install Supervisor and place the files in the appropriate directory.

How do I install Supervisor on Ubuntu/Debian?

You can install Supervisor using: sudo apt update && sudo apt install supervisor. After installation, place your generated .conf files in /etc/supervisor/conf.d/ and run sudo supervisorctl reread && sudo supervisorctl update.

What's the difference between queue workers and Horizon?

Queue workers are basic Laravel processes that handle background jobs, while Horizon is a dashboard and process manager for Redis-based queues. Horizon provides advanced features like job monitoring, scaling, and balancing. Use queue workers for simple setups and Horizon for complex Redis-based queue management.

How many queue workers should I run?

The number of queue workers depends on your server resources and job volume. Start with 2-4 workers per CPU core, but monitor your system resources. Too many workers can cause memory issues, while too few may create bottlenecks. Use monitoring tools to find the optimal number for your application.

What if my queue workers keep failing?

Check your Laravel logs first: tail -f storage/logs/laravel.log. Common issues include memory limits, database connection problems, or job-specific errors. Ensure your environment variables are correct and your database connections are stable. The generated config includes auto-restart settings to handle temporary failures.

Can I use this with Laravel 12?

Absolutely! This tool is designed to work with all Laravel versions, including Laravel 12. The generated configurations are compatible with the latest Laravel features and best practices. The tool automatically adapts command syntax and configuration options for optimal Laravel 12 compatibility.

How do I monitor my Supervisor processes?

Use sudo supervisorctl status to check process status, sudo supervisorctl tail [process_name] to view logs, and sudo supervisorctl restart [process_name] to restart specific processes. For web-based monitoring, consider tools like Laravel Horizon or Supervisor's built-in web interface.

What environment variables should I set?

Essential environment variables include APP_ENV=production, QUEUE_CONNECTION=redis (or your preferred queue driver), REDIS_HOST, DB_CONNECTION, and any API keys your jobs need. The tool provides common environment variables, but customize them based on your application's requirements.

Can I run this on shared hosting?

Supervisor typically requires root access and is not available on shared hosting. For shared hosting, consider using Laravel's built-in queue:work command with a cron job, or look into managed queue services like Laravel Forge, Envoyer, or cloud-based solutions like AWS SQS with Lambda.

Which cloud provider should I choose for Laravel with Supervisor?

Both Digital Ocean and Hetzner are excellent choices. Digital Ocean offers better documentation and community support, while Hetzner provides better performance and pricing. For beginners, Digital Ocean is recommended due to its user-friendly interface and extensive tutorials. For cost-conscious users or those needing high performance, Hetzner is the better choice.

What's the difference between LAMP and LEMP stacks?

LAMP uses Apache (Linux, Apache, MySQL, PHP) while LEMP uses Nginx (Linux, Nginx, MySQL, PHP). Nginx is generally faster and more efficient for static content and reverse proxying, while Apache has better .htaccess support and is easier to configure for beginners. For Laravel applications, both work well, but Nginx is often preferred for production environments.

How do I troubleshoot Supervisor configuration errors?

Start by checking Supervisor status with sudo supervisorctl status, then examine logs with sudo supervisorctl tail [process_name]. Common issues include incorrect file paths, permission problems, or missing PHP extensions. Use the troubleshooting section in this guide for step-by-step debugging procedures.

Can I use Supervisor with Laravel Reverb (WebSockets)?

Yes! Supervisor is perfect for managing Laravel Reverb WebSocket servers. Use the custom process configuration with the command php artisan reverb:start --host=0.0.0.0 --port=8080. This ensures your WebSocket server stays running and automatically restarts if it crashes.

What are the security considerations for Supervisor?

Always run Supervisor processes as non-root users (like www-data), set proper file permissions (644 for config files, 755 for directories), use environment variables for sensitive data, and configure firewalls to restrict access. Never store passwords or API keys directly in configuration files.

How do I scale queue workers on cloud providers?

Start with 2-4 workers per CPU core and monitor resource usage. Use numprocs in your Supervisor configuration to run multiple instances. For high-traffic applications, consider using load balancers and multiple servers. Both Digital Ocean and Hetzner support easy server scaling through their control panels.

What's the best way to deploy Laravel with Supervisor?

Use a deployment script that: 1) Updates your application code, 2) Runs composer install and npm build, 3) Updates Supervisor configurations, 4) Reloads Supervisor with sudo supervisorctl reread && sudo supervisorctl update, and 5) Restarts processes. Consider using Laravel Forge or Envoyer for automated deployments.