Neil Turner's Blog

Blogging about technology and randomness since 2002

Updating WordPress without using FTP


Despite the fact that it’s been almost two years since I switched to WordPress, I’m still learning new things about it. For example, I always assumed that WordPress needed to use FTP to update itself, and to install and update plugins.

It turns out that actually, it doesn’t need to use FTP, and arguably, if WordPress is using FTP to update itself then you’re doing it wrong. FTP is actually a fall-back that WordPress uses when it can’t update itself due to permissions problems.

In my case, the user account I use for FTP is different to the user account that Apache uses for reading and writing. So when I installed WordPress, all of the files were owned by my FTP username. Apache could access them, but couldn’t write to them. So when WordPress wanted to update itself, it asked for my FTP credentials so that it could modify its files.

To change this, I changed the ownership of WordPress’ files to www-data, which is Apache’s user account, with the following commands:

sudo chown -R www-data:www-data wp*
sudo chown -R www-data:www-data index.php
sudo chown -R www-data:www-data readme.html
sudo chown -R www-data:www-data license.txt
sudo chown -R www-data:www-data xmlrpc.php

There’s probably a way of doing this with just one command but I’m not that great at Unix.

Doing this allowed plugin installs and upgrades to run without being prompted for FTP login details. However, I haven’t tried updating the whole of WordPress yet, since both the installs I manage are running the latest version. I’ve recently had trouble getting WordPress upgrades to work automatically so I’m hoping that this will fix the issue – I’ve had to install both versions 3.5 and 3.5.1 manually, which is a pain.

One Comment

  1. Huh – learn something new every day! Like you, I always understood that the upgrade script was only possible by FTP, which I wasn’t about to enable for one application.

    If you have multiple installations of WordPress running, I recommend a script by Aaron Toponce, – been using this for a while now (with some modifications) and never had a problem with it.