I am running nginx, mariadb and php8.2-fpm on my WSL2 Ubuntu server successfully, all running as user
www-data just fine, however, I cannot upload files from the web interface. When I attempt to, the nginx error log records the following:
2023/05/03 09:27:46 [error] 1339#1339: *1 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception Drupal\Core\File\Exception\FileWriteException: "The destination directory 'public://2023-05' is not writable" at /var/www/html/repo/web/core/modules/media_library/src/Form/FileUploadForm.php line 332" while reading response header from upstream, client: ::1, server: localhost, request: "POST /media-library?media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_image&media_library_opener_parameters%5Bentity_type_id%5D=node&media_library_opener_parameters%5Bbundle%5D=article&media_library_opener_parameters%5Bfield_name%5D=field_image&media_library_opener_parameters%5Bentity_id%5D=144&media_library_opener_parameters%5Brevision_id%5D=741&hash=q_RtKmTw2wyucMR1nnKCucBF2P1b1crtsxJDMyk7fW8&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "localhost", referrer: "http://localhost/"
Thinking that the issue may be with nginx and php8.2-fpm, I've also successfully configured apache to run with php8.2 and similarly get this error inside of Apache's error log:
[Wed May 03 09:28:32.068299 2023] [php:notice] [pid 1195] [client ::1:59860] Uncaught PHP Exception Drupal\Core\File\Exception\FileWriteException: "The destination directory 'public://2023-05' is not writable" at /var/www/html/repo/web/core/modules/media_library/src/Form/FileUploadForm.php line 332, referer: http://localhost:8080/
nginx, mariadb and php-fpm are all running as
www-data and the folder permissions are all set to
chown -R www-data:www-data ./) with full access to the files (
chmod -R 777 ./).
I've also added the following to my
[automount] enable = true root = /mnt/ options = "metadata,umask=22,fmask=11" mountFsTab = false
PHP is still unable to write to write files. Any ideas on how to deal with write permissions on WSL 2 instances of Ubuntu?