Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I stop WordPress from prompting me to enter FTP information when doing updates?

share|improve this question
    
I +1 this because of the answer more then the question :) –  Tal Galili Sep 6 '10 at 18:41

3 Answers 3

up vote 13 down vote accepted

If you edit your wp-config.php file you can preload these FTP settings as constants read by WordPress. Keep in mind, on a shared host, you should be mindful of possible security implications. See Editing wp-config.php for more information.

Your settings will vary, but these work for me and my hosting setup. I've included some of the unused constants, prefixed:

define('FS_METHOD', 'direct');
define('FTP_BASE', '/usr/home/username/public_html/my-site.example.com/wordpress/');
define('FTP_CONTENT_DIR', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/plugins/');
// define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
// define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
define('FTP_USER', 'my-ftp-username');
define('FTP_PASS', 'my-ftp-password');
define('FTP_HOST', 'ftp.my-site.example.com');
// define('FTP_SSL', false);
share|improve this answer
    
that's a great tip! –  pixeline Aug 11 '10 at 20:37
    
Huh, I did not know you could do that! I'll have to remember that one. –  Grant Palin Aug 11 '10 at 23:42
    
This is the simplest way, but as pixeline says below, check file permissions. Two of the three credentials are stored in the database, but the third is written to a file (I can't remember which it is off the top of my head). –  John P Bloch Aug 12 '10 at 13:17
    
Very very cool - thanks for the tip! –  Tal Galili Sep 6 '10 at 18:41

Check your file ownership. When the user that apache runs as can write to the wordpress directories, then the integrated upgrade process all just works without ftp. The FTP credentials are for if the web server doesn't have the right priviledges on your files, then wordpress prompts you for your FTP details, and attempts to use those to FTP back to the same server it is on to be able to write the files it needs.

share|improve this answer
1  
You really shouldn't modify file ownership to that of the webserver, as this is a potential security risk. –  Otto Oct 20 '11 at 1:23
    
...unless it was badly set up, as it was in my case :) –  pixeline Oct 20 '11 at 9:35

It seems that not only does WordPress check if the directories are writable, but it checks if the Apache user OWNS the directories (or at least, if the Apache user owns the temporary file it creates). Observe these lines of code at /wp-admin/includes/file.php: get_filesystem_method():

    if ( $temp_handle ) {
        if ( getmyuid() == @fileowner($temp_file_name) )
            $method = 'direct';
        @fclose($temp_handle);
        @unlink($temp_file_name);
    }

So, a quick solution will be to issue this command and give ownership of the whole Wordpress installation to Apache:

sudo chown -R www-data wordpress/

Where www-data is the Apache user, and of course wordpress is your WordPress installation folder.

I have further documented my solution here: http://ardeearam.com/blog/2012/11/11/solved-wordpress-asking-for-ftp-credentials-when-upgrading/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.