I ran into problems with the auto-upgrade facility of WordPress on my sites hosted here, on NearlyFreeSpeech.net.

Through trial and error, I established the following works:

  1. Add the following lines to wp-config.php:
    define('FS_METHOD', 'direct');
    define('FTP_BASE', '/public/');
    define('FTP_CONTENT_DIR', '/public/wp-content/');
    define('FTP_PLUGIN_DIR ', '/public/wp-content/plugins/');
    define('FTP_USER', '---your username---');
    define('FTP_HOST', 'ssh.phx.nearlyfreespeech.net:22');
    define('FTP_PASS', '---your password---');
    
  2. Using PuTTY, log-in.
  3. Enter the following command: chgrp -R web *. This will change the group ownership of all files and directories to web. This is the required ownership for WordPress to perform the upgrade.
  4. Enter the following command: chmod -R 777 *. This will change the permissions on all files and directories to full public access.
  5. Perform any WordPress upgrades; core, plugins or themes. It shouldn’t ask for any connection details.
  6. Enter the following command: find . -type d -print0 | xargs -0 chmod 755. This will reset all directory permissions to read-only for everyone except the owner (you).
  7. Enter the following command: find . -type f -print0 | xargs -0 chmod 644. This will reset all file permissions to read-only for everyone except the owner (you).
  8. Enter the following command: chmod -R 775 wp-content. This will update the permissions on the wp-content directory to be 775, allowing uploads, including from the media library.

You only have to do steps 1 and 3 once. Steps 4 to 8 have to be performed for upgrade.

Although not essential, the last three steps should be performed, as it is highly insecure to leave permissions set as public (777).

Also using SSH rather than FTP conforms with the view of NearlyFreeSpeech.net that FTP should not be used as passwords are transferred in plaintext.

Thanks to SNARP for the original article.

One Response to “Upgrading WordPress on NearlyFreeSpeech.net”

Trackback this entry.

[...] Then, when I tried to automatically upgrade WordPress (which I hadn’t done in a long time) I got a load of errors. First, I couldn’t get WordPress to connect to my hosting account. I added the code below to wp-config.php and that problem was fixed (which I found here). [...]

Leave a Reply

(required)

(required)