Stumble Digg Technorati Delicious

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.

//*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);

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 :)


Add your comment here or use Facebook below.

23 Responses to “How To: Stop WordPress Asking For FTP details To Upgrade Plugins”

  1. Comment by esabeth posted on September 29th, 2009

    Very easy, indeed. Thnx!

    Reply to this comment

  2. Comment by Greg posted on October 17th, 2009

    Thanks for the hint on suPHP. I run a VPS and always wondered why it asked for FTP. I installed suPHP, restarted Apache and – BAM – it no longer asks!

    THANKS!
    .-= Greg´s last blog ..How To: Insert Google Analytics or Mint Tracking Code in Thesis =-.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on October 17th, 2009

      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.

      Reply to this comment

  3. Comment by Rick posted on February 27th, 2010

    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.

    Reply to this comment

  4. Comment by Jesse posted on February 27th, 2010

    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.

    Reply to this comment

  5. Comment by Spunky Jones posted on May 25th, 2010

    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.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on May 25th, 2010

      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.

      Reply to this comment

  6. Comment by Marc Lipovsky (Twitter name: ) posted on August 13th, 2010

    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!

    Reply to this comment

  7. Comment by Marc Lipovsky (Twitter name: ) posted on August 13th, 2010

    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!

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on August 13th, 2010

      Hi Marc,

      Glad you “sort of” have it working.. I honestly haven’t tried it locally like that, are you running a FTP server on your local machine?

      Reply to this comment

      • Comment by Marc Lipovsky (Twitter name: ) posted on August 14th, 2010

        Thanks Jesse. I’m not running an ftp server. I’m using MAMP for running php, apache, and mysql.

        Reply to this comment

        • Comment by Jesse (Twitter name: ) posted on August 14th, 2010

          I would guess then that its a file ownership issue, if that is not set correctly it wont be able to overwrite the files.. Personally I haven’t tried it that way yet.

          Reply to this comment

  8. Comment by Theo (Twitter name: ) posted on September 22nd, 2010

    Great peace of code, thanks !

    Reply to this comment

  9. Comment by Theo (Twitter name: ) posted on September 22nd, 2010

    Sorry it should be “piece” , so peace brother, peace ;)

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on September 22nd, 2010

      lol, trust me.. I’m not one to pick about spelling :) thanks for the thanks and thanks for stopping by, glad you found it useful.

      Reply to this comment

  10. Comment by Brian Parnall (Twitter name: ) posted on March 21st, 2011

    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

    Reply to this comment

  11. Comment by pepper posted on April 28th, 2011

    Your solution worked without a hitch.

    Thank you!

    Reply to this comment

  12. Comment by Kadabra (Twitter name: ) posted on July 18th, 2011

    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.

    Reply to this comment

  13. Comment by Mohamad (Twitter name: ) posted on September 10th, 2011

    Thank you finally i have founded a way to prevent my blog from asking ftp :)

    Reply to this comment

  14. Comment by Derrick posted on April 18th, 2012

    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.

    Reply to this comment

    • Comment by Jesse (Twitter name: ) posted on April 18th, 2012

      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

      Reply to this comment


Leave a Reply

""

Member Login