If you try and install a WordPress plugin or upgrade to a newer version through the admin console you might get this error message and a prompt to enter FTP details:
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed.
Contrary to what it says, you don’t actually need to enter your FTP credentials, you just need to set the correct permissions for WordPress to be able to write to it’s own directory. How this is done depends on your hosting environment, which is why it prompts for FTP credentials as that it definitely the easiest way, but if like me you don’t have FTP you’ll need to change things yourself.
Option 1: Set the correct user
The first thing to try is setting the correct user, check the configurations for whatever web server you are using, and chown the files in the WordPress directory to be owned by that user:
$ sudo chown -R www-data:www-data /var/www/wordpress
Option 2: Set more writable permissions
If that doesn’t work (for example if like me you have WordPress running in Docker), the easiest option is to just set the directory to be writeable by everyone. This is less secure though, so only do this if you are sure about what you are doing:
$ sudo chmod -R 777 /var/www/wordpress
After that you’ll be able to update plugins and WordPress itself directly from the admin console!
Still not working?
If it’s still not working and you are sure you have permissions set correctly (try uploading attaching an image to a post), you can force WordPress into skipping the permissions check. Add the following to wp-config.php:
If it’s still not working, sorry, you’ll just have to update WordPress manually 🙁