to perform the requested action wordpress needs to access your web server. please enter your ftp

I'm following Changing File Permissions « WordPress Codex, yet when I'm try to update and/or install plugin and/or theme through wp-admin, I'm getting following:

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.

from file system level:

# ls -ld wp-content/ wp-content/plugins/ wp-content/themes/
drwxrwxr-x.  6 root apache 4096 Jun  2 12:01 wp-content/
drwxrwxr-x. 28 root apache 4096 Jun  2 00:00 wp-content/plugins/
drwxrwxr-x. 11 root apache 4096 May 11 16:34 wp-content/themes/

httpd runs as apache:

$ ps auxw | grep httpd
root     20158  0.0  0.1 533080 26192 ?        Ss   15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20233  0.0  0.2 612608 34908 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20234  0.0  0.2 538772 46904 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20235  0.0  0.1 536832 24268 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20236  0.0  0.2 626272 35640 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20237  0.0  0.0 535296  9592 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20322  0.0  0.1 537088 26620 ?        S    15:03   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20380  0.0  0.2 626060 33816 ?        S    15:04   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20429  0.0  0.1 538216 29184 ?        S    15:04   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20447  0.0  0.2 629380 43180 ?        S    15:04   0:00 /usr/sbin/httpd -DFOREGROUND
apache   20448  0.0  0.2 626172 35224 ?        S    15:04   0:00 /usr/sbin/httpd -DFOREGROUND
alexus   24073  0.0  0.0 112652   972 pts/9    R+   15:13   0:00 grep --color=auto httpd

I'd like to be able to perform requested action (install and/or update) through /wp-admin without FTP credentials.

How can I do that?


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 / Commandline Prompt after connecting to your Server via SSH:

sudo chown -R apache:apache /var/www/html

Checkout this article for full details.

Add the following to wp-config.php:

define( 'FS_METHOD', 'direct' );

Let me know how it works for you.

Even though it is totally correct to have the ownership as root:apache with permissions 775, and httpd to run as apache, Wordpress does not like this. It wants the owner to be apache, as per wp-admin/includes/file.php:

    // Attempt to determine the file owner of the WordPress files, and that of newly created files
   $wp_file_owner = $temp_file_owner = false;
   if ( function_exists('fileowner') ) {
      $wp_file_owner = @fileowner( __FILE__ );
      $temp_file_owner = @fileowner( $temp_file_name );

Yours would be:
wp_file_owner = root
temp_file_owner = apache

if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
    // WordPress is creating files as the same owner as the WordPress files,
    // this means it's safe to modify & create new files via PHP.
    $method = 'direct';
    $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
} elseif ( $allow_relaxed_file_ownership ) {
    // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
    // safely in this directory. This mode doesn't create new files, only alter existing ones.
    $method = 'direct';
    $GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership';

If $wp_file_owner is same as $temp_file_owner then proceed. Yours would be caught in the elseif, which according to the comment does not allow delete/create, but only updates (I verified this by updating the code of a plugin from within Wordpress, and it worked).

Note I did not extensively look through the code, this is just my quick interpretation. I had the same problem and once I switched user:group so that the httpd user is also the file owner, it did not prompt for FTP credentials anymore.

Tags: Plugins / Themes / Updates

Similar questions

The requested content cannot be loaded. Please try again later for image gallery
I am using jquery fancybox and want to show gallery images but when I click on image it show me error "The requested content cannot be loaded. Please try again later". I want to add fancybox to my ajax content.. without ajax there is no problem. I am using this code .
Change Wordpress default registration error text [Error: This username is invalid because it uses illegal characters. Please enter a valid username.]
May I know how could I change the error text? Example, I want change it from. [Error: This username is invalid because it uses illegal characters. Please enter a valid username.] to [Error: Username invalid. Please enter a valid username.]
WordPress FTP Error: "Failed to connect to FTP Server"
I have an issue i've been trying to fix for two days now. I've searched the web and tried to apply multiple suggestions from other posters. So i have a self hosting web server: CentOS7, Apache, PHP, MariaDB, OpenSSH and Pure-FTPd. I found a nice guide combining MariaDB and pure-FTPd. I used vsftp beforehand but later found the use of database to st...
WooCommerce error when removing billing fields: "Please enter an address to continue."
I've removed billing fields on the WooCommerce checkout page by adding the following lines to functions.php: This does remove the billing fields and leaves the shipping fields in-tact, as desired. However, now I get an error on checkout: However, all shipping fields are filled out. The request is being sent via AJAX (/shop/checkout?wc-ajax=checkout...
Download a file on FTP to other FTP server
this is my first question here, please correct me if a few things are not adequate. My problem is the following: I have a file on an FTP account of my client's provider, normally it would be simple I copy the HTTP URL, but the provider blocks this options. I want to integrate it into the website and since this famous file is updated every day, I ne...
My Wordpress plugin needs Facebook API access. Should each user create a Facebook app for access?
The title pretty much says it all. I'm writing a Wordpress plugin that needs Facebook API access. In order to get Facebook API access, it is neccessary to create a Facebook "App". I plan to release this plugin to the public. Would it be best practice for me to use a single Facebook app that I have created as the access point for everyone's API requ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.