Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deansatch's avatar

Non root user and bootstrap/cache

I have loads of laravel projects in Envoyer and every single one of them has been a nightmare to set up permission-wise.

The problem:

  • bootstrap/cache must be owned by the user www-data
  • The non-root ssh user is used to deploy from Envoyer so the whole app is owned by theUser

The solution to the above is to add in the deployment hook (run as root) to chown -R www-data bootstrap/cache. This makes the app work, however, now Envoyer cannot purge old releases as it can't delete the bootstrap directory since it is owned by www-data.

Adding theUser to the www-data group doesn't help as it is read-only for the group.

When I look at a forge project I notice Envoyer runs as the user forge. The app resides in the /home/forge/ directory. Firstly, how did they get it to work? Secondly, I have read that you should NEVER serve a website from within the home directory? Update: Just checking permissions on a forge project I see that bootstrap dir is set to 775. How does it do this without doing it in the deployment hook??

I have been searching now for years for a definitive guide on how to correctly setup a non-root user Envoyer deployment with no luck. Ideally we should be able to create multiple vhosts on a server, giving them their own directory at /var/www/{theVhostUser}/ then be able to connect Envoyer as that user without the need for root.

Can anyone else share their setups that have worked?

0 likes
1 reply
joby_h's avatar

I’m not an Envoyer user at present but do use Forge and hopefully can shed some light on part of your issue.

Laravel Forge runs Nginx as the forge user on Ubuntu, not www-data, and sets the web root for each project using Nginx's configuration files. Therefore on a Forge provisioned server it is not necessary to change the owner of the cache directory.

If you have access to Forge you can see the site’s web root configuration by scrolling to the bottom of a site dashboard and selecting Files > Edit Nginx Configuration.

Nginx is set to run as the forge user for all sites on a Forge provisioned server via the main /etc/nginx/nginx.conf file.

Please or to participate in this conversation.