0

How To Update WordPress Without FTP Access

Posted by Arch on April 17, 2019
How to Update WordPress Without FTP Access

Sometimes you can’t update your WordPress and plugins without using an FTP account. This usually happens when WordPress can’t directly communicate with your /wp-content folder.

Even if this happens to you, there are certain ways that you can bypass this issue and modify WordPress without FTP access.

What Happens?

When your web server has permission to reach all the necessary files, it will automatically update WordPress and all the plugins you have installed. This doesn’t mean that you need to have FTP/SFTP or SSH access. Instead, you just need to set up certain file permissions on your web server. The system will try all methods, and if nothing works, it will return to FTP.

It happens in this order:

  1. The system tries to write a file to /wp-content.
  2. If it is successful, it will start comparing the ownership of the file with its unique-identifier (UID). If it matches, you’ll be able to install all the extensions and update WordPress.
  3. If this method fails, the system will notify you that it can’t update.

If you don’t want to depend on this automatic check, you can define a constant in your /wp-config. This constant is usually an ‘FS_Method’.

Enter an ‘FS_METHOD’

The quickest way to solve this issue is to define a constant. This is useful when you don’t want to depend on automatic check to identify the best filesystem to use. You can do this by defining an ‘FS_Method’ in your /wp-config.php file.

Here is how to do it:

Find /wp-config.php

Before you do anything, you need to open the /wp-config.php file. You can find it the WordPress root folder. If you have trouble finding it, you can also find it in your WordPress installer folder. The file location is wordpress/wp-config.php

wp-config

Insert an FS_METHOD

You will need to paste a code in your php file. Below the last line of code, you should add:

define('FS_METHOD','direct');

update wordpress without ftp access

Once you add this code, you will bypass the issue. When you type it, you may upload the file to your website’s root folder on the server and it should have no trouble working in an instant.

By fixing the FTP problem, you’ll be able to install add-ons, extensions, website themes, and other updates.

Details About FS_METHOD

FS_METHOD will force a filesystem method. You should only choose one of the following four: direct, ssh2, ftptext, or ftpsockets. The code from the previous example used the ‘direct’ method. These methods are sorted by preference. First preference is ‘direct’ and the fourth is ‘ftpsockets’.

  1. “direct” is the First Preference. This setting is the one that the system chooses automatically. It forces the system to use Direct File/IO requests within PHP. On hosts with bad configuration, these requests can cause security issues.
  2. “ssh2” is the Second Preference. This setting forces the system to use the SSH PHP extension if you have it installed.
  3. “ftptext” is the Third Preference. This setting forces the system to use the FTP PHP extension for FTP access.
  4. “ftpsockets” is the Fourth Preference.

You shouldn’t implement this code unless you are experiencing issues with your update. So, if you don’t notice any improvements after changing it, consider changing it back or removing it. Usually, the ‘ftpsockets’ option should work if automatic updates fail.

Alternative: Get the SSH SFTP Updater Support

WordPress recently added a plugin called SSH SFTP Updater Support that may fix this issue. This plugin will keep your WordPress installation updated at all times. It uses phpseclib (secure communications library) to get over this problem.

When you install this app, go to /wp-config.php and insert the code:

define (‘FS_Method’, ‘ssh2’);

Once you do, you will have much less trouble dealing with servers in SFTP and SSH.

For Advanced Users: Manually Enabling SSH2

If you want to enable SSH2 for your updates, plugins, and theme uploads, you will need to make your own SSH keys and install the PHP SSH module. When you do this, WordPress will see that you have SSH2 available. This means that you will see an SSH2 option when you’re performing an upgrade.

You create SSH keys by typing a code:

ssh-keygen
cd~/.ssh
cp id_rsa.pub authorized_keys

Then you change the permission so you gain access to these files by WordPress:

cd ~
chmod 755 .ssh
chmod 644 .ssh/*

wordpress update without ftp access

In Conclusion

The FTP problem often appears if you use shared hosting and the permissions and ownership overlap, thus causing a conflict. For this reason, it is good to define an “FS_METHOD” so you can update and modify your WordPress without ever having to provide any FTP details.

Leave a Reply

Your email address will not be published. Required fields are marked *


Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.