How To: Stop WordPress Asking For FTP details To Upgrade Plugins

Are you tired of  WordPress Asking For FTP details every time you want to add, delete or upgrade a plugin?

This starts off as a minor annoyance, but after time can grow to be one of those things that can drive you crazy or make you wonder why it’s happening when it didn’t happen before, or doesn’t happen on other sites that you have that are on other servers.

I will show you s simple way to fix WordPress Asking For FTP details and give you a brief explanation about why this happens. WordPress is picky about file ownerships and who can do what with those files. If your server uses a different username than what wordpress expects for the site it won’t allow it access without you providing those FTP login credentials every time you need to add, delete or upgrade a plugin. If you are on a shared host you will likely never see this happen but if you are on a VPS or Dedicated server it’s quite likely that you will, but don’t worry its a very simple work around to stop WordPress asking For FTP details. If you wish to, installing suPHP on your server will also fix this issue or you can read on for the other alternative.

First off, you will need to open up your wp-config.php file (which if you are doing things right will be one directory above your sites root directory) and in this wp-config.php file you just simply have to add your ftp loing information and you will never have to type it in again, so without further ado heres the bit of code you want to add to your wp-config.php file.

[php]
//*added ftp login credentials to avoid WordPress asking for FTP details every time I wanted to upgrade a plugin*
define(‘FTP_HOST’, ‘ftp.yoursite.com’);
define(‘FTP_USER’, ‘Your_FTP_Username’);
define(‘FTP_PASS’, ‘Your_FTP_password’);
//*If you can use a SSL connection set this to true*
define(‘FTP_SSL’, true);[/php]

That’s it, set these options, save the file and you are all set. Your WordPress asking for FTP details days are over, happy “easy” plugin upgrading :)

23 thoughts on “How To: Stop WordPress Asking For FTP details To Upgrade Plugins”

    • Glad to be of help, especially for a fellow cheesehead (even if you don’t live in WI anymore)

      Hope Alabama is treating you well, I stopped by your site and checked it out, looks good.

  1. It happens because your directory permissions are not set correct. When WordPress cannot directly download a file, it will try to FTP it. Your WordPress files (and directories) need to be owned by the same user and group as what your Apache web server is running as (which is usually “apache”). This allows the web server to write to your WordPress directory.

    So, an easy fix would be to secure shell in to your site and do the following… let's say your WordPress is in the “httpdocs” directory located under /var/www, you would change to the /var/www directory then run “chown -R apache:apache httpdocs”. You run that without the quotes of course, and substitute the correct username in the place of “apache” if your server process runs as a different user. The -R tells it to be recursive so that it will change all of your WordPress files and directories.

    There is one small drawback to doing this… after this, you won't be able to FTP files to the site… you'll have to use the built in WordPress tools for working on your site, adding images, etc. If you ever need to FTP files to the site, you would need to do the same steps as above but change “apache” to your ftp username. After you do your upload, repeat the steps above. You can of course change just single directories… if you always upload in to wp-content/mymedia or something like that, then just “chown” that directory to be owned by your ftp credentials and leave the rest owned by Apache and you'll be able to do both.

  2. Hi, thanks for stopping by. you are correct but i feel a much easier
    solution is to use suPHP on the server to manage the ownerships properly so
    wordpress and ftp work as they should, just a much easier situation for most
    people out there.

  3. For many people, filling out your FTP password is annoying. This code would be nice for those who don’t want to be bothered with filling in the pwd. There is a plugin that takes care of this as well, however, sometimes the amount of plugins you have active can get out of hand.

    The biggest concern to me is, what if someone gets access to your blog? They would be able to delete all of your plugins, because they have FTP access. I am not sure, but they could also upload their own PHP script into your plugin folder. Could they gain root access of your server by doing this?

    For me, I use a password program. It allows me to copy and paste my FTP pwd. It is still annoying, but much safer.

    • Convenience is a good thing, you just need to weigh the risk and reward and see what sits best with you. If someone gains access to your site your in bad shape anyhow (most default WordPress installs don’t ask for FTP credentials)

      If you follow a few “best practices” for security you can mitigate much of the risk and sleep better at night.. I actually offer some WordPress backup and security packages that my clients really like as well.

  4. What if your running WordPress locally? I’m using MAMP to run multiple localhosts and I’ve tried entering a few different things but it doesn’t seem to work. I’m just being lazy cause I don’t want to have to go into my files and delete it but it’d just be easier when I’m working in the WP admin.

    Any thoughts would be helpful. Thanks!

  5. Actually this kind of works for me now but I do get this message when I do this now:

    Plugin could not be deleted due to an error: Unable to locate WordPress Plugin directory.

    Thanks!

  6. Thanks for the code

    What do you do if the the ftp is not ftps? Put false, or leave that part of code out altogether?

    Thanks

    Brian

  7. It quite a frustrating issue this. Especially when you’re used to everything working out the box.

    I find that on cpanel hosts it’s fine but on non-cpanel servers it’s an issue.

  8. Thanks for this. Even after a couple of years this post is still useful. I’ve just developed a site for a .aero client and their host has all kinds of restrictions on permissions.

    • Glad you found it useful :) some things have a long shelf life indeed lol.. reminds me that I really should get back to posting on this blog

Comments are closed.