Wordpress - wordpress on localhost lamp doesn't let me install plugins
The solution I found that worked on my Mac running the built-in Apache2 was to add this to 'wp-config.php'
define('FS_METHOD','direct');
Keep this to a localhost or dev setup and don't use it for production.
This is a permissions issue. wp-content/plugins must be writable by the web server user.
After installing WordPress 5 on Debian 9 Stretch I updated (remotely on localhost) and was prompted for FTP details.
Running these commands in terminal fixed the problem:
chown -R www-data:www-data /var/www/html
chmod -R g+rwX /var/www/html
It's a file-ownership issue.
Code and caveat from turnkeyLinux.com:
Changing file permissions is a trade off (often increasing security reduces user-friendliness and/or usability). For security 'best practice' only the folders that require write access by the webserver should be owned by the webserver. If your webserver has write access everywhere and your server is compromised it makes it easier to hack your WordPress install) but for ease of use giving the webserver ownership should resolve all your issues...