# Install & Setup Supervisor

In this short snippet, you will learn how to install and manage [Supervisor](http://supervisord.org/) in Ubuntu machine. The steps is very straight forward so let's get started.<br>

#### Step 1: Install Supervisor in Linux

**Ubuntu**

To install supervisor in ubuntu you can use "apt-get" command line. Do note that you need to use "sudo" in order to run this command.

```
sudo apt-get install supervisor
```

**CentOS**

To install supervisor in centOS (used by most whm server) you can use "yum" command line. Do note that you need to use "sudo" in order to run this command.

```
sudo yum update -y
sudo yum install epel-release
sudo yum update
sudo yum -y install supervisor
```

Then start and enable the supervisord daemon to start on boot using the commands below:

```
sudo systemctl start supervisord
sudo systemctl enable supervisord
```

#### Step 2: Supervisor Configuration

The supervisor configuration can be located in **"/etc/supervisor/conf.d"** or **"/etc/supervisord.d" (in centOS)** and from within this directory, you can create as many configurations as you like.

For this example, we'll set up Laravel Queue supervisor configuration. To create a new file from within the supervisor config directory called "**queue\_manager.conf**" or "**queue\_manager.ini**" and the content of the file should be as follows.

Create the config file using the command below:

**Ubuntu**

```
nano /etc/supervisor/conf.d/queue_manager.conf
```

**CentOS**

```
nano /etc/supervisord.d/queue_manager.ini
```

Then paste the follow code in the file:

```
[program:laravel_queue]
process_name=%(program_name)s_%(process_num)02d
command=php /PATH_TO_YOUR_BACKEND/artisan queue:work --tries=1
startsecs = 0
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stderr_logfile=/PATH_TO_YOUR_BACKEND/storage/logs/laraqueue.err.log
stdout_logfile=/PATH_TO_YOUR_BACKEND/storage/logs/laraqueue.out.log
stderr_logfile_maxbytes=200KB
stdout_logfile_maxbytes=200KB
```

In the code above, you have to replace the following with the right values on your server:\
**PATH\_TO\_*****YOUR\_BACKEND** replace with the directory path of where you backend files is location, usually its something like **home/USERNAME/public\_*****html**

**user=forge**, change it to the user you are logged in in your terminal, usually is root user, so you can set: **user=root**

#### Step 3: Start Supervisor

Once you have created the configuration, you can start the supervisor process. To start supervisor you can run the following commands.

```
sudo supervisorctl reread
sudo supervisorctl update
```

#### **Step 4: Start the queue**

Run the command below to start just the laravel\_queue you just created above

<pre><code><strong>sudo supervisorctl start laravel_queue
</strong></code></pre>

<mark style="color:red;">**Note:**</mark> If nothing works after run the command above, you can rather run the command below, to make supervisor start all queue:

```
sudo supervisorctl start all
```

**Done!!**
