Wordpress localhost ftp

47,887

Solution 1

In my experience, WordPress can be a bit fussy about permissions and ownership when it comes to self-update without FTP, so using FTP to localhost is a perfectly valid tactic, I'd say. But as others have said, just ensuring that everything from your WordPress root directory on downwards is writable by the PHP process, and owned by the same user, may well be enough to avoid the need for FTP.

If you do want to use FTP, are you sure you've enabled the FTP server? If so, you should just use a user who has permission to get to the directory via FTP (you can test with the command-line ftp tool.) As my sites are set up in my personal Sites directory, I just use my normal username and password (e.g. for /Users/matt/Sites/whatever I log in as matt.)

Other things to check: What happens if you try ftp localhost on the command line? Can you log in there?

Solution 2

Update as mentioned by Chaudhry Waqas in comments it might be sufficient to just add define('FS_METHOD', 'direct'); to wp-config.php, so please try this first as it's safer not to change access rights if not necessary

WARNING: only do this on your local computer, it's a huge security risk on a public installation!

I haven't tried it but as mentioned by @misterfancypants comment, changing those settings only for wp-content/plugins/ should be sufficient
updated to incorporate this info

This one worked for me

$ cd /Users/<username>/Sites
# (wordpress = name of the directory, change as needed)
$ sudo chown -R :_www wordpress
$ sudo chmod -R g+w wordpress

and then add following in wp-config.php

define('FS_METHOD', 'direct');

found on http://soderlind.no/running-wordpress-locally-on-mac-os-x-lion/#crayon-533a956214a8e343167867

Cheers Can

Solution 3

I fixed it by:

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

Updated on 03-05-2019

cd /var/www
sudo chown -R www-data:www-data [YOUR_WORDPRESS_PROJECT_DIR]

Solution 4

Actually, problem is that WordPress create a temp file to check the file permissions

and it compare that temp file's owner with its a core file's owner (refer fileowner()) both should match. in most of the case, it does not match on localhost hence we extracted wp files in different user access and PHP has its own user group.

So there are 2 ways to solve this problem.

Way 1:

cd wordpress
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;

and following

define( 'FS_METHOD', 'direct' );

in wp-config.php

This does not check any fileowners just uses the direct file system

way 2

set

sudo chown -R www-data:www-data wordpress

This sets the both WordPress into www-data use so actually the temp file(which created by WordPress) also comes inside this user, So both fileowners is same so problem solves

More info refer : https://developer.wordpress.org/reference/functions/get_filesystem_method/

Solution 5

Add this in your config.php file,

define('FS_METHOD','direct');
Share:
47,887
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I have wordpress running on my localhost on mac Lion.

    Everytime I try to install or delete plugins it asks me for hostname, ftp username and ftp password.

    I configured my localhost to 127.0.0.1, but I have never configured the ftp username and password for my localhost. How can I get which user and password it's by default?

    I have tried almost every user and pass I have on mysql, my osx admin, etc. with no results.

    Any ideas?

  • RAC
    RAC over 9 years
    This worked for me on a mac after WP started complaining about FTP credentials when trying to update plugins.
  • Alan L.
    Alan L. over 9 years
    This was by far the simplest solution. If anyone gets confused by this, make sure to replace 'wordpress' to the name of your wordpress directory ` sudo chown -R :_www [your directory name]`
  • andydavies
    andydavies about 8 years
    Worked for me, but on my OS (Ubuntu) I changed 'wordpress' to 'html' in the second command you list.
  • kuldipem
    kuldipem about 8 years
    wordpress is just placeholder here, it should be replaced by your root of the app.
  • ijoseph
    ijoseph over 5 years
    So it looks like it's setting the group to be _www. Is this group documented anywhere as being used by WP?
  • Can Rau
    Can Rau over 5 years
    @ijoseph WP does not use any group or user specifically by itself afaik, I'm not sure right now what exactly set this group up but as it's part of the linked article it might come from MAMP (most probably), Apache, or macOS. WP shouldn't really care about user/group as long as it's able to read and write its files ;)
  • majorobot
    majorobot over 5 years
    A word of warning here: the chown and chmod commands are too broad. This changes the group and the group permissions on the whole WP installation. You should be able to just change perms on the wp-content/plugins/ directory (and then quickly change them back). All this might be ok on your local environment, but definitely not recommended on a remote server.
  • Can Rau
    Can Rau over 5 years
    @misterfancypants You're absolutely right, based on the question I assumed it's clear that it's only meant on a private computer / installation, I'll add a warning to my answer, thanks for the hint!
  • Chaudhry Waqas
    Chaudhry Waqas about 5 years
    add only define('FS_METHOD', 'direct'); in config file worked for me.
  • FooBar
    FooBar about 5 years
    Instead of this, as @Can suggests, use define('FS_METHOD', 'direct'); inside wp-config.php instead. Safer than messing around with permissions.