How to Install and Setup Supervisor in Ubuntu for Laravel?

By Hardik Savani November 5, 2023 Category : Laravel

Hi Artisan,

In this quick example, let's see laravel setup supervisor. you will learn laravel queue supervisor ubuntu. This example will help you laravel install supervisor. In this article, we will implement a laravel setup supervisor.

If you are using laravel queue in your project then in your server you have to setup supervisor. so, i will show you how to install and manage supervisor in ubuntu for laravel project. so, let's see the following step to make it done.

Step 1: Install Supervisor in Ubuntu

To install supervisor on Ubuntu, simply run the given command on the command line.

sudo apt-get install supervisor

Step 2: Supervisor Configuration

In this step, we will configure laravel project queue setup with supervisor. so, let's run the below command to go on supervisor directory.

cd /etc/supervisor/conf.d

Next, we will create laravel-worker.conf configuration file with following code. you need to update your laravel project path. update following code:

sudo nano laravel-worker.conf

/etc/supervisor/conf.d/laravel-worker.conf

[program:laravel-worker]

process_name=%(program_name)s_%(process_num)02d

command=php /home/forge/example.com/artisan queue:work sqs --sleep=3 --tries=3 --max-time=3600

autostart=true

autorestart=true

stopasgroup=true

killasgroup=true

user=forge

numprocs=8

redirect_stderr=true

stdout_logfile=/home/forge/app.com/worker.log

stopwaitsecs=3600

Step 3: Start Supervisor

To initiate the supervisor process, you can launch it by executing the following three commands after configuring it.

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start laravel-worker:*

Now, you are ready to run your queue process.

Step 4: Send Mail using Queue

You can create example for email sending with queue from here: Laravel 10 Send Email using Queue Example

I hope it can help you...

Tags :
Shares