Can't install plugin and theme

16,577

Solution 1

You might also want to check the ownership of the folder: try this

sudo chown -R www-data:www-data /var/www

Solution 2

After a clean install of Wordpress locally, add below statement

define("FS_METHOD", "direct"); to my wp-config.php file.

Later change the ownership of the wp-content and the contents inside the wp-content folder to the web server user (_www) I used the below commands.

sudo chown _www:_www wp-content

sudo chown _www:_www wp-content/*

Alternatively you can also set the permission recursively using

sudo chown -R _www:_www wp-content/

Solution 3

It complains about FTP credentials when it cannot access the filesystem.

Most likely your permissions are wrong (directory inaccessible by webserver)

If you ensure that your wordpress directory is owned by the same user who runs your webserver, the FTP credentials note should disappear and you should be able to install themes and plugins via Wordpress Admin console.

Share:
16,577
petercheung
Author by

petercheung

Updated on August 11, 2022

Comments

  • petercheung
    petercheung almost 2 years

    i want to install some plugin but show

    Installation failed: Could not create directory.
    

    that i find some solution add some code to wp-config

    //* FTP Settings **/
    /** wp-content path */
    
    define('FS_METHOD', 'ftpext');
    define('FTP_BASE', '/');
    
    define('FTP_CONTENT_DIR', '/wp-content/');
    define('FTP_PLUGIN_DIR', '/wp-content/plugins/');
    define('FTP_USER', 'ftpuser');
    define('FTP_PASS', 'ftppewd');
    define('FTP_HOST', 'domain.com');
    
    define('FTP_SSL', false);
    
    define("FS_METHOD", "direct");
    define("FS_CHMOD_DIR", 0777);
    define("FS_CHMOD_FILE", 0777);
    

    that the error message change to

    Installation failed: Unable to connect to the filesystem. Please confirm your credentials

    . i use IIS 8 use ftp client the ftp account has full access right

    • milan kyada
      milan kyada almost 8 years
      why did you use both ftpext and direct with FS_METHOD only one is enough either direct or ftpext? I suggest you to use define("FS_METHOD", "direct"); remove other constants
    • petercheung
      petercheung almost 8 years
      if not add any thing the error show >Installation failed: Unable to locate WordPress content directory (wp-content).
    • milan kyada
      milan kyada almost 8 years
    • petercheung
      petercheung almost 8 years
      if add define("FS_METHOD", "direct"); the error is Installation failed: Could not create directory.
    • milan kyada
      milan kyada almost 8 years
      give write permission to wp-content
  • Jeet
    Jeet over 5 years
    I believe this is more correct and should be the accepted answer, since most of the cases permission on www is problem.
  • Sayed
    Sayed over 4 years
    Among other things, adding define("FS_METHOD", "direct"); and define("FTP_SSL", false); fixed my problem!
  • MIA
    MIA over 4 years
    running this sudo chown -R _www:_www [root directory] fixed it for me.