You have to setup group permission
For instance, if your app is owned by www-data:www-data
-
add user to www-data group
-
allow write to group : chmod -R g+w /var/www
or vice-versa
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Basically I have a GCP VM instance that I access from GCPs browser SSH.
I've uploaded the servers ssh public key to my github account, and I want to run
git clone [email protected]:myuser/myproject.git in the /var/www/ folder.
But I don't have the correct permissions to do that.
I could solve this by running
sudo chown -R $USER:www-data /var/www However, now Laravel doesn't have the correct permissions ( /storage/logs/laravel.log could not be opened in append mode: Failed to open stream: Permission denied)
If I do sudo chown -R www-data:www-data /var/www/myproject I don't get this error anymore, but can no longer run git commands.
Basically, what permissions would be the correct ones to set the project folder? I still want to be able to run git and composer without sudo, but laravel also need the correct permissions to run correctly.
You have to setup group permission
For instance, if your app is owned by www-data:www-data
add user to www-data group
allow write to group : chmod -R g+w /var/www
or vice-versa
Please or to participate in this conversation.