Search code examples
phpsymfonyubuntuserversymfony5

Symfony5 cannot deploy code to the server, permission issue


I am attempting to deploy my Symfony production code to an Ubuntu server.

I have everything set up and I can deploy fine if I set the permissions to the web folder to 777, but if I try to set it to 755, git cannot write to the folder.

I have done the following:

 sudo chown -R www-data:www-data /var/www/website/
 sudo chmod -R 755 /var/www/website/

But I get a failed to write files notice from git.

Now if I change the permissions to 777, it works fine.

If I ls -la, this is what I get:

 drwxr-xr-x 13 www-data www-data 4096 Dec 17 19:19 website

What am I missing here?


Solution

  • You'll either need to make your user a member of the www-data group.

    $ usermod -a -G $USER www-data
    

    or run git as the www-data user.

    $ sudo -u www-data git ...