Hello Stanislas, I am Henry and I want to share my insight about your issue.
The problem is that when you edit files from Windows Explorer, the Linux permissions are reset. Your /etc/wsl.conf settings are for a different purpose and won't fix this. The solution is to run these commands inside your Ubuntu terminal. They force your project folder to automatically assign the correct group (www-data) to all new files and folders, even when created from Windows.
The Fix:
Run these three commands in your Ubuntu terminal. Replace /path/to/your/project with your actual project path.
- Set ownership to your user and the www-data group
-
sudo chown -R $USER:www-data /path/to/your/project
- Give the group write permissions
-
sudo chmod -R g+w /path/to/your/project
- Make all new files inherit the 'www-data' group
-
sudo chmod g+s /path/to/your/project
Online References for Details:
- Why this works (setgid bit): The chmod g+s command is the key. It forces group inheritance.
- Reference: Linuxize - chmod Command (setgid section)
- How WSL file systems work: Understanding the interaction between Windows and Linux.
Hope this clears things up