The prompt for SFTP and FTP details means that you don’t have the right permissions to download or upgrade plugins or the WordPress core.
The most probable reason is that the ownership of your local files is incorrect, but it’s also potentially a permissions issue.
The owner of the files in your project needs to be the Apache user. The easiest way to find out your Apache user is to run this command while the service is running.
Some common users are www or www-data. So now let’s update your project root. Let’s say it is /var/www/projectName and that our Apache user turned out to be www-data:
Now you can attempt the upgrade or install again. More than likely you are up and running, but if not let’s reset file permissions.
Since you are on your local there is no security risk here. Just make sure you don’t pass these permissions on to the live site when you deploy.
In some limited hosting environments, you will also get this prompt on your live site. There isn’t a lot you can do here except get a better host, or deal with a slight inconvenience.
The apache user in Ubuntu is typically “www-data”, like you mentioned, but in RHEL based servers like CentOS, it’s simply “apache”.
Also, I prefer the change of user for the files, rather than the permissions change because the permissions change is annoying to reverse and can be a big security issue, especially on a shared host.
I ran into the problem myself when installing WordPress MultiSite on my linux machine for development. The solution that worked for me (file permissions didn’t, I tried :\) was to add a line to my config file:
Without that line in my config file, all plugin and theme install requests were met with a form asking for FTP info.