# Ubuntu/Debian
sudo apt-get update
sudo apt-get install supervisor
# CentOS/RHEL
sudo yum install supervisor
cd /opt/homebrew/var/www/staff/apm
sudo ./setup-supervisor.sh
# Check Supervisor status
sudo supervisorctl status
# Check queue worker logs
tail -f storage/logs/worker.log
# Check scheduler logs
tail -f storage/logs/scheduler.log
If the automated setup doesn't work, follow these steps:
# Copy worker configuration
sudo cp supervisor-laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf
# Copy scheduler configuration
sudo cp supervisor-laravel-scheduler.conf /etc/supervisor/conf.d/laravel-scheduler.conf
# Set proper ownership
sudo chown -R www-data:www-data /opt/homebrew/var/www/staff/apm/storage/logs
sudo chmod -R 755 /opt/homebrew/var/www/staff/apm/storage/logs
# Reload configuration
sudo supervisorctl reread
sudo supervisorctl update
# Start services
sudo supervisorctl start laravel-worker:*
sudo supervisorctl start laravel-scheduler:*
# Overall status
sudo supervisorctl status
# Specific service status
sudo supervisorctl status laravel-worker:*
sudo supervisorctl status laravel-scheduler:*
# Start services
sudo supervisorctl start laravel-worker:*
sudo supervisorctl start laravel-scheduler:*
# Stop services
sudo supervisorctl stop laravel-worker:*
sudo supervisorctl stop laravel-scheduler:*
# Restart services
sudo supervisorctl restart laravel-worker:*
sudo supervisorctl restart laravel-scheduler:*
# Restart all
sudo supervisorctl restart all
# Queue worker logs
tail -f storage/logs/worker.log
# Scheduler logs
tail -f storage/logs/scheduler.log
# Laravel application logs
tail -f storage/logs/laravel-$(date +%Y-%m-%d).log
# Check Supervisor logs
sudo tail -f /var/log/supervisor/supervisord.log
# Check configuration syntax
sudo supervisorctl reread
# Check file permissions
ls -la storage/logs/
# Check if workers are running
ps aux | grep "queue:work"
# Check failed jobs
php artisan queue:failed
# Process one job manually
php artisan queue:work --once --verbose
# Fix ownership
sudo chown -R www-data:www-data storage/logs/
sudo chmod -R 755 storage/logs/
# Fix file permissions
sudo chmod +x artisan
# Check memory usage
free -m
# Reduce worker memory limit
# Edit /etc/supervisor/conf.d/laravel-worker.conf
# Change --memory=512 to --memory=256
sudo supervisorctl restart laravel-worker:*
# Use the monitoring script
./queue-monitor.sh status
# Check database directly
php artisan tinker
>>> \App\Models\Job::count()
>>> \App\Models\FailedJob::count()
# Test mail configuration
php artisan tinker
>>> Mail::raw('Test email', function($msg) { $msg->to('test@example.com')->subject('Test'); });
php artisan tinker
>>> DB::connection()->getPdo();
For high-traffic sites, increase the number of workers:
# Edit /etc/supervisor/conf.d/laravel-worker.conf
# Change numprocs=2 to numprocs=4
sudo supervisorctl reread
sudo supervisorctl update
Set up log rotation to prevent disk space issues:
# Create logrotate configuration
sudo nano /etc/logrotate.d/laravel-worker
Add this content:
/opt/homebrew/var/www/staff/apm/storage/logs/worker.log {
daily
missingok
rotate 14
compress
notifempty
create 644 www-data www-data
postrotate
supervisorctl restart laravel-worker:*
endscript
}
Set up monitoring to alert when services fail:
# Create monitoring script
nano /opt/homebrew/var/www/staff/apm/monitor-supervisor.sh
Add this content:
#!/bin/bash
WORKER_COUNT=$(sudo supervisorctl status | grep "laravel-worker" | grep "RUNNING" | wc -l)
if [ $WORKER_COUNT -eq 0 ]; then
echo "ALERT: No queue workers running!"
# Add your alert mechanism here (email, Slack, etc.)
fi
Make it executable and add to crontab:
chmod +x monitor-supervisor.sh
crontab -e
# Add: */5 * * * * /opt/homebrew/var/www/staff/apm/monitor-supervisor.sh
After setup, verify everything is working:
sudo supervisorctl statusps aux | grep "queue:work"php artisan queue:failedtail -f storage/logs/worker.logIf you encounter issues:
tail -f storage/logs/worker.logsudo supervisorctl statushtop or topphp artisan tinker then DB::connection()->getPdo()php artisan tinker then Mail::raw('Test', function($msg) { $msg->to('test@example.com')->subject('Test'); });