Laravel Forge – Supervisor Setup For Multiple Users

Server management has never been easier as with Laravel Forge. It literally has everything you need. If you are using supervisor to manage your workers then this tutorial is for you. In today’s blog article we are going to explore how to set up multiple Forge users to have access to supervisor instead of the traditional root user.

Step 1: Connect To Your Server Using SSH

Build a ssh connection to your server by using the credentials listed in Forge.

Step 2: Add Users And A Dedicated Group For Supervisor

Adding multiple users in unix operating system ain’t complicated. Let’s say we wanted to add bob as our new user.

sudo useradd -m bob

sudo passwd bob

Great, now let’s create a dedicated group which we are going to use for our supervisor process and add the desired users to this group.

sudo groupadd supervisor

sudo usermod -a marius -G supervisor

sudo usermod -a bob -G supervisor

Step3: Edit supervisord.conf

Now we need to edit our supervisord.conf on our machine so that every user with the supervisor group can access supervisor.

You can open the config with whatever editor you like:

sudo vim /etc/supervisor/supervisord.conf

Change / add these lines to your config:

chmod=0770

chown=marius:supervisor ;socket file uid:gid owner

Save, exit and restart supervisor:

sudo -A systemctl restart supervisor

Conclusion

That’s it! Now every user can have access to supervisor without being required to log in as the root user. This was a quick one and I wish you a nice day! Happy coding! 

Useful links:

Managing users and groups:

https://superuser.com/questions/636726/allow-users-of-a-certain-group-to-run-a-command-without-sudo

Configuring supervisor:

https://stackoverflow.com/questions/31541685/allow-user-other-than-root-to-restart-supervisorctl-process
https://discuss.erpnext.com/t/error-class-permissionerror-errno-13-permission-denied-file-usr-lib-python3-dist-packages-supervisor-xmlrpc-py-line-560/93632/5
Marius Cristea
Full stack developer @ Control F5
OUR WORK
Case studies

We have helped 20+ companies in industries like Finance, Transportation, Health, Tourism, Events, Education, Sports.

READY TO DO THIS
Let’s build something together