I host WordPress on AWS EC2 (Ubuntu) and encounter the following error while updating plugins:
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.
rwx
permission has been granted to the user www-data
. Here is what I do.
<!– language: lang-bash –>
# Add a new group
groupadd www-pub
# Add the user `www-data` to the group 'www-pub'
usermod -a -G www-pub www-data
# Change the ownership of '/var/www/' to 'ubuntu:www-pub'
chown -R ubuntu:www-pub /var/www
# Change the permissions of all the folders to 2775
find /var/www -type d -exec chmod 2775 {} +
# Change the permissions of all the files to 0664
find /var/www -type f -exec chmod 0664 {} +
As you can see, www-data
has all the right permissions, but I am still required to enter the FTP credentials. What is the reason and how can I fix it?
There is a simple fix. Just edit file wp-config.php and write this code inside it.
First try this:
Note: Do not add this to the end of the file, but just below the database information on the top of the file.
Also please read this blog post.
This means that WordPress is having limited permission for making changes in the folder that it was installed.
In-order to fix this, all that you need to do is provide necessary permissions for the same.
Run the following command in your terminal, PuTTY, or command line prompt after connecting to your Server via SSH.
Checkout the below article for full details (Syam | MMWYS.Online):
How to fix the infamous issue of WordPress asking for FTP Credentials for Installing Plugins / Themes?
I suspect that this answer explains why it isn’t working.
Most Ubuntu web servers I have seen are set up a bit differently from what you’re doing. I’m not sure what your reason is for doing it that way, but if you wanted to keep things simple you would just set the owner and group for all files to
www-data
:That will grant the web server full access to all of your files in the web root. If you needed to grant any additional users access to those files, you would just add them to the
www-data
group.The file permissions you’ve set up look good to me as-is.
For reference, this answer explains what
chmod 2775
(specifically the 2) means.Essentially, it causes any new files to inherit the group of the directory.
www-data
in this case. This means the web server will have access to any files created by other users, without having to change the ownership or permissions of those files.You need to assign a user to your project.
For NGINX Servers:
For Apache Servers:
And change directory permissions:
Add this line
define( 'FS_METHOD', 'direct' );
of code in yourwp-config.php
file afterdefine( 'WP_DEBUG', true );
.So it should be like this:
Save the file and try again.