How to Install and Configure Supervisor for Laravel Workers on Linux
This guide explains how to install Supervisor via pip or yum, configure supervisord.conf and a Laravel worker configuration file, handle common errors, set permissions, and start and manage Laravel queue workers using supervisorctl on a Linux system.
Supervisor is a Python‑based process management tool that can be installed on most Linux distributions. It allows you to keep background services such as Laravel queue workers running reliably.
Installation methods
1. pip installation (or easy_install):
yum install python-setuptools
easy_install pip
pip install supervisor # or easy_install supervisor
mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisor/supervisord.conf
mkdir -p /etc/supervisor/conf.d2. yum installation (recommended) :
yum install supervisor
mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisor/supervisord.conf
mkdir -p /etc/supervisor/conf.dModify the main configuration
vim /etc/supervisor/supervisord.conf
# Add or uncomment the include section
[include]
files = /etc/supervisor/conf.d/*.confCreate a Laravel worker configuration file
vim /etc/supervisor/conf.d/laravel-worker.confInsert the following content (replace paths with your own):
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /www/your_path/artisan queue:work redis --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/www/your_path/storage/logs/workers.logSave and exit the file (e.g., :wq ).
Set directory permissions
chmod -R +x /etc/supervisor/conf.dStart supervisord
supervisord -c /etc/supervisor/supervisord.confIf you encounter an error that another program is already listening on a required port, shut it down first:
supervisorctl shutdownFor socket‑related errors, you may need to recreate the socket file and adjust its permissions:
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo supervisorctl -c /etc/supervisor/supervisord.confRestart supervisord to apply changes:
supervisord -c /etc/supervisor/supervisord.confVerify that the daemon is running:
ps -ef | grep 'supervisord'Start the Laravel worker
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*After the worker starts, you can manually test the queue processing:
php /www/your_path/artisan queue:start
php /www/your_path/artisan queue:work redis --sleep=3 --tries=3These commands run the Redis and database queue workers respectively.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.