{"id":1696,"date":"2024-10-03T05:06:43","date_gmt":"2024-10-03T05:06:43","guid":{"rendered":"https:\/\/debugspot.com\/?p=1696"},"modified":"2024-10-03T05:26:41","modified_gmt":"2024-10-03T05:26:41","slug":"install-configure-supervisor-laravel-linux","status":"publish","type":"post","link":"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/","title":{"rendered":"6 Easy Steps: How to Install and Configure Supervisor for a Laravel Application on Linux"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/debugspot.com\/blogs\/wp-content\/uploads\/2024\/10\/1723733058372.png\" alt=\"Configure Supervisor\" \/><\/p>\n<p>Laravel Supervisor is a powerful process monitoring tool that ensures your Laravel application\u2019s background tasks, such as queue processing and task scheduling, run smoothly and reliably. In this guide, we\u2019ll walk through the steps to set up Laravel Supervisor on a Linux server, enabling you to manage your Laravel instance tasks efficiently.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_1_Install_Supervisor\" >Step 1: Install Supervisor<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#For_DebianUbuntu\" >For Debian\/Ubuntu:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#For_CentOSRHEL\" >For CentOS\/RHEL:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_2_Configure_Supervisor_for_Laravel_Queues\" >Step 2: Configure Supervisor for Laravel Queues<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#21_Create_a_Supervisor_Configuration_File\" >2.1 Create a Supervisor Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#22_Add_the_Following_Configuration\" >2.2 Add the Following Configuration<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_3_Update_Supervisor_Configuration\" >Step 3: Update Supervisor Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_4_Start_the_Laravel_Worker\" >Step 4: Start the Laravel Worker<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_5_Monitor_the_Worker_Process\" >Step 5: Monitor the Worker Process<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Check_the_Status_of_the_Worker\" >Check the Status of the Worker:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Restart_the_Worker_Process\" >Restart the Worker Process:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Stop_the_Worker_Process\" >Stop the Worker Process:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Step_6_Ensure_Supervisor_Starts_on_Boot\" >Step 6: Ensure Supervisor Starts on Boot<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#For_DebianUbuntu-2\" >For Debian\/Ubuntu:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#For_CentOSRHEL-2\" >For CentOS\/RHEL:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Troubleshooting_Tips\" >Troubleshooting Tips<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#Summary\" >Summary<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/debugspot.com\/blogs\/install-configure-supervisor-laravel-linux\/#You_may_also_find_interesting\" >You may also find interesting:<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"Step_1_Install_Supervisor\"><\/span>Step 1: Install Supervisor<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Supervisor is available through the default package manager on most Linux distributions. Follow the installation steps below for your specific operating system:<\/p>\n<h5><span class=\"ez-toc-section\" id=\"For_DebianUbuntu\"><\/span><strong>For Debian\/Ubuntu:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo apt-get update\r\nsudo apt-get install supervisor\r\n<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"For_CentOSRHEL\"><\/span><strong>For CentOS\/RHEL:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo yum install epel-release\r\nsudo yum install supervisor\r\n<\/code><\/pre>\n<p>This will install Supervisor and its related dependencies on your Linux system. After the installation, Supervisor should be running as a background service. You can check its status using the command:<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo systemctl status supervisor\r\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"Step_2_Configure_Supervisor_for_Laravel_Queues\"><\/span>Step 2: Configure Supervisor for Laravel Queues<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Once Supervisor is installed, you need to create a configuration file to manage your Laravel application&#8217;s queue workers. This configuration file will define how Supervisor should start, stop, and monitor your worker processes.<\/p>\n<h5><span class=\"ez-toc-section\" id=\"21_Create_a_Supervisor_Configuration_File\"><\/span><strong>2.1 Create a Supervisor Configuration File<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>To create a Supervisor configuration file for Laravel, run the following command:<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo nano \/etc\/supervisor\/conf.d\/laravel-worker.conf\r\n<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"22_Add_the_Following_Configuration\"><\/span><strong>2.2 Add the Following Configuration<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p>Add the following content to the laravel-worker.conf file:<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">[program:laravel-worker]\r\nprocess_name=%(program_name)s_%(process_num)02d\r\ncommand=php \/path-to-your-laravel-project\/artisan queue:work --sleep=3 --tries=3 --timeout=90\r\nautostart=true\r\nautorestart=true\r\nuser=your-user-name\r\nnumprocs=3\r\nredirect_stderr=true\r\nstdout_logfile=\/path-to-your-laravel-project\/storage\/logs\/worker.log\r\n<\/code><\/pre>\n<p>In this configuration:<\/p>\n<ul>\n<li><strong>command<\/strong>: Specifies the command to run the Laravel queue worker.<\/li>\n<li><strong>autostart<\/strong>: Automatically starts the process when Supervisor starts.<\/li>\n<li><strong>user<\/strong>: Sets the user under which the process should run. Replace your-user-name with your Linux username.<\/li>\n<li><strong>numprocs<\/strong>: Number of worker processes to start. Adjust this based on your server\u2019s capacity and application needs.<\/li>\n<li><strong>stdout_logfile<\/strong>: Sets the log file location for the output of the worker processes. Ensure this path is writable by the specified user.<\/li>\n<\/ul>\n<p><strong>Pro Tip: If you have a high volume of queued jobs, consider increasing the numprocs value to create multiple worker processes.<\/strong><\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_3_Update_Supervisor_Configuration\"><\/span>Step 3: Update Supervisor Configuration<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>After creating the configuration file, you need to update Supervisor to read the new configuration:<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo supervisorctl reread\r\nsudo supervisorctl update\r\n<\/code><\/pre>\n<p>These commands tell Supervisor to read any new configuration files and apply them to its process management.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_4_Start_the_Laravel_Worker\"><\/span>Step 4: Start the Laravel Worker<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>To start the Laravel worker process defined in the configuration, use the following command:<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo supervisorctl start laravel-worker:*\r\n<\/code><\/pre>\n<p>This command will start all the worker processes defined under the laravel-worker configuration.<\/p>\n<p><strong>Pro Tip: If you want to start only specific processes, replace * with the process number, like laravel-worker:1.<\/strong><\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_5_Monitor_the_Worker_Process\"><\/span>Step 5: Monitor the Worker Process<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Supervisor provides several commands to help you monitor and control your worker processes. Here are some useful commands:<\/p>\n<h5><span class=\"ez-toc-section\" id=\"Check_the_Status_of_the_Worker\"><\/span><strong>Check the Status of the Worker:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo supervisorctl status\r\n<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"Restart_the_Worker_Process\"><\/span><strong>Restart the Worker Process:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo supervisorctl restart laravel-worker:*\r\n<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"Stop_the_Worker_Process\"><\/span><strong>Stop the Worker Process:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo supervisorctl stop laravel-worker:*\r\n<\/code><\/pre>\n<p>These commands provide full control over the Laravel worker processes managed by Supervisor.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_6_Ensure_Supervisor_Starts_on_Boot\"><\/span>Step 6: Ensure Supervisor Starts on Boot<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>To make sure Supervisor starts automatically when your server boots, you need to enable the Supervisor service:<\/p>\n<h5><span class=\"ez-toc-section\" id=\"For_DebianUbuntu-2\"><\/span><strong>For Debian\/Ubuntu:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo systemctl enable supervisor\r\n<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"For_CentOSRHEL-2\"><\/span><strong>For CentOS\/RHEL:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre class=\"highlight-height line-numbers language-javascript\"><code class=\"language-javascript\">sudo systemctl enable supervisord\r\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"Troubleshooting_Tips\"><\/span><strong>Troubleshooting Tips<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>If you encounter any issues during installation or configuration, here are some troubleshooting tips:<\/p>\n<ul>\n<li><strong>Logs Not Updating<\/strong>: Ensure the path to the log file specified in the configuration is correct and that the user running process manager has write permissions to that file.\n<\/li>\n<li><strong>Process Not Starting<\/strong>: Double-check the command paths in the configuration file. Ensure that your Laravel project directory is correct and accessible.\n<\/li>\n<\/ul>\n<p>For more detail you can write <a href=\"https:\/\/laravel.com\/docs\/11.x\/readme\" target=\"_blank\" rel=\"noopener\">Laravel Documentation<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>background job manager is a robust tool for managing processes in your Laravel project, and with the steps outlined above, you should be able to install, configure, and monitor your Laravel queues and workers with ease.<\/p>\n<h5><span class=\"ez-toc-section\" id=\"You_may_also_find_interesting\"><\/span>You may also find interesting:<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<p><a title=\"Effortlessly Upload Images to AWS S3 in Laravel | Complete Step-by-Step Guide\" href=\"https:\/\/debugspot.com\/blogs\/how-to-upload-image-in-aws-s3-in-laravel\/\" target=\"_blank\" rel=\"noopener\">Effortlessly Upload Images to AWS S3 in Laravel | Complete Step-by-Step Guide<br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel Supervisor is a powerful process monitoring tool that ensures your Laravel application\u2019s background tasks, such as queue processing and task scheduling, run smoothly and reliably. In this guide, we\u2019ll walk through the steps to set up Laravel Supervisor on a Linux server, enabling you to manage your Laravel instance tasks efficiently. Step 1: Install Supervisor Supervisor is available through the default package manager on most Linux distributions. Follow the installation steps below for your specific operating system: For Debian\/Ubuntu: sudo apt-get update sudo apt-get install supervisor For CentOS\/RHEL: sudo yum install epel-release sudo yum install supervisor This will install Supervisor and its related dependencies on your Linux system. After the installation, Supervisor should be running as a background service. You can check its status using the command: sudo systemctl status supervisor Step 2: Configure Supervisor for Laravel Queues Once Supervisor is installed, you need to create a configuration file to manage your Laravel application&#8217;s queue workers. This configuration file will define how Supervisor should start, stop, and monitor your worker processes. 2.1 Create a Supervisor Configuration File To create a Supervisor configuration file for Laravel, run the following command: sudo nano \/etc\/supervisor\/conf.d\/laravel-worker.conf 2.2 Add the Following Configuration Add the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"rank_math_lock_modified_date":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1696","post","type-post","status-publish","format-standard","hentry","category-laravel"],"acf":[],"_links":{"self":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1696"}],"collection":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/comments?post=1696"}],"version-history":[{"count":9,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1696\/revisions"}],"predecessor-version":[{"id":1698,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/posts\/1696\/revisions\/1698"}],"wp:attachment":[{"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/media?parent=1696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/categories?post=1696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debugspot.com\/blogs\/wp-json\/wp\/v2\/tags?post=1696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}