DEV Community

loading...
Cover image for Install supervisor on AWS EB with Laravel

Install supervisor on AWS EB with Laravel

Rabeea
Software Developer
Updated on ・2 min read

In this article, we will see how to install Supervisor on AWS Elastic Beanstalk with Laravel.

Prerequisites:

• I assume you deployed your Laravel project on AWS Elastic Beanstalk & make all configurations of queue & etc.
• Connect to SSH.
• I'm using Amazon Linux 2 (Nginx server).
• PHP 7.4 installed on AWS.

After connect to ssh follow these steps:

Step 1: Install EPEL

The EPEL repository is an additional package repository that provides easy access to install packages for commonly used software.

$ sudo amazon-linux-extras install epel
Enter fullscreen mode Exit fullscreen mode

Step 2: Install supervisor

Let's install supervisor run the following command.

$ sudo yum install -y supervisor
Enter fullscreen mode Exit fullscreen mode

Step 3: Edit configuration file

Go to the default configuration file.

$ sudo vim /etc/supervisord.conf
Enter fullscreen mode Exit fullscreen mode

Change the include directory at the end to:

files = supervisord.d/*.conf
Enter fullscreen mode Exit fullscreen mode

Step 4: Create new files

Add a new configuration file. If the directory doesn’t exist, then make one.

$ sudo vim /etc/supervisord.d/NameYouLike.conf
Enter fullscreen mode Exit fullscreen mode

Give the setting:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan queue:work sqs --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/app/current/storage/worker.log
stopwaitsecs=3600
Enter fullscreen mode Exit fullscreen mode

Note ⭕️

In command line, I'm using SQS for the queue, if you are using (Database or Redis) you should change it to the thing that you are using.

Step 5: Launch Supervisor

$ sudo supervisord -c /etc/supervisord.conf
Enter fullscreen mode Exit fullscreen mode

Step 6: Apply The Changes

Apply new setting and check the status

$ sudo supervisorctl update;
$ sudo supervisorctl status
Enter fullscreen mode Exit fullscreen mode

You should see something like that:

Superviser

That it 🥳🚀

Discussion (0)