Posts Learn Components Snippets Categories Tags Tools About
/

How to Install Supervisor in Ubuntu for Laravel Project

Learn how to install Supervisor in Ubuntu for Laravel project to run processes such as Laravel Horizon

Created on Sep 15, 2021

3854 views

In this short snippet, you will learn how to install and manage Supervisor in Ubuntu machine. The steps is very straight forward so let's get started.

Step 1: Install Supervisor in 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

Step 2: Supervisor Configuration


The supervisor configuration can be located in "/etc/supervisor/conf.d" and from within this directory, you can create as many configurations as you like.
/etc/supervisor/conf.d
For this example, we'll set up Laravel Horizon supervisor configuration. To create a new file from within the supervisor config directory called "horizon.conf" and the content of the file should be as follows.
[program:horizon]
process_name=%(program_name)s
command=php /home/forge/example.com/artisan horizon
autostart=true
autorestart=true
user=forge
redirect_stderr=true
stdout_logfile=/home/forge/example.com/horizon.log
stopwaitsecs=3600

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

sudo supervisorctl start horizon

Other Reads

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)