FTP Credentials requested when trying to activate WordPress Theme

Solution:1

It’s definitely a files & directories permission issue. Move the define('FS_METHOD','direct'); line back to where it was (that change is causing a different error).

The ‘www-data’ user is the default user for Apache (and other HTTP servers?), in case you didn’t know.

Solution:2

This solution is quite simple and may solve your problem in a matter of seconds.

Simply add the following code to your wp-config.php file:

define('FS_METHOD','direct');

This forces WordPress to use the “direct” PHP method for automatic updates, rather than utilizing FTP.

Once you’ve added this code, save the file and reattempt the update/installation that originally caused the error. If it installs normally, you’re good to go!

Solution:3

If the first method didn’t work for you, you can also add your FTP information directly to your wp-config.php file. This will allow WordPress to install updates via FTP without continuing to prompt you for your credentials.

To do so, add the following code to your wp-config.php file:

define('FTP_USER', 'USERNAME');
define('FTP_PASS', 'PASSWORD');
define('FTP_HOST', 'FTP.EXAMPLE.COM');

Be sure to replace the username, password, and host with your own details. Check with your web host if you’re unsure about any of this information.