the title was “WordPress: Unable to create directory”, but unfortunately, error “unable to create directory” occurred with trying to add theme, plugin, media file, update WordPress or any other websites uploaded with sftp
First step is to add the current user to the group www-data (Apache):
sudo gpasswd -a "$USER" www-data
sudo chown -R “$USER”:www-data /var/www – not sure in this step
Change the rights for group for modifications and executions
sudo chgrp -R www-data /var/www/html sudo chmod -R g+w /var/www/html
to make it’s working for Apache + SFTP, let’s do these:
# sudo apt-get install acl is already install in bookworm sudo setfacl -d -m u::rwx /var/www/html sudo setfacl -d -m g::rwx /var/www/html sudo setfacl -d -m o::r /var/www/html sudo chmod g+s /var/www/html getfacl /var/www/html getfacl: Removing leading '/' from absolute path names # file: var/www/html # owner: pi # group: www-data # flags: -s- user::rwx group::rwx other::r-- default:user::rwx default:group::rwx default:other::r--
sources:
How to Fix the Unable to create directory Error in WordPress | Tips and Tricks HQ
https://askubuntu.com/questions/46331/how-to-avoid-using-sudo-when-working-in-var-www