For those who have their wordpress root folder under their home folder:
** Ubuntu/apache
CREDIT Granting write permissions to www-data group
You want to call usermod
on your user. So that would be:
sudo usermod -aG www-data yourUserName
** Assuming www-data
group exists
Check your user is in www-data
group:
groups yourUserName
You should get something like:
youUserName : youUserGroupName www-data
** youUserGroupName is usually similar to you user name
Recursively change group ownership of the wp-content folder keeping your user ownership
chown yourUserName:www-data -R youWebSiteFolder/wp-content/*
Change directory to youWebSiteFolder/wp-content/
cd youWebSiteFolder/wp-content
Recursively change group permissions of the folders and sub-folders to enable write permissions:
find . -type d -exec chmod -R 775 {} \;
** mode of `/home/yourUserName/youWebSiteFolder/wp-content/' changed from 0755 (rwxr-xr-x) to 0775 (rwxrwxr-x)
Recursively change group permissions of the files and sub-files to enable write permissions:
find . -type f -exec chmod -R 664 {} \;
The result should look something like:
WAS:
-rw-r--r-- 1 yourUserName www-data 7192 Oct 4 00:03 filename.html
CHANGED TO:
-rw-rw-r-- 1 yourUserName www-data 7192 Oct 4 00:03 filename.html
Equivalent to:
chmod -R ug+rw foldername
Permissions will be like 664 for files or 775 for directories.
P.s. if anyone encounters error 'could not create directory'
when updating a plugin, do:
server@user:~/domainame.com$ sudo chown username:www-data -R wp-content
when you are at the root of your domain.
Assuming: wp-config.php
has
FTP credentials on LocalHost
define('FS_METHOD','direct');