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


Install Apache Web Server

sudo apt install apache2

go to apache2.conf

sudo nano /etc/apache2/apache2.conf

and remove ‘Indexes’ to hide the content of the directory if index.html or index.php are missing:

<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted