Unable to create directory

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

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

to make it’s working for Apache + SFTP, let’s do these:

passwd -a “$USER” www-data

sudo apt-get install acl

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--

Leave a Reply

Your email address will not be published. Required fields are marked *

Yandex.Metrica