wp-config.php » WordPress FS_METHOD explained

WordPress FS_METHOD explained

The constant FS_METHOD determines the filesystem method that WordPress should use for reading, writing, modifying, or deleting files.

To set a different method for file editing, simply edit your wp-config.php file and add the line:

define( 'FS_METHOD', 'VALUE FROM THE TABLE BELLOW' );

The FS_METHOD forces the filesystem method and accepts the following values:

MethodDescription
directUse Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts.
ssh2Force the usage of the SSH PHP Extension if installed.
ftpextForce the usage of the FTP PHP Extension for FTP Access with provided credentials.
ftpsocketsUse the PHP Sockets Class for FTP Access with provided credentials.

FS_METHOD direct

Generally, you should only change the FS_METHOD value if you are experiencing update problems. If you change it and it doesn’t help, change it back/remove it. Under most circumstances, setting it to ‘ftpsockets’ will work if the automatically chosen method does not.


FS_METHOD ftpext

To use FTP for upgrades define in the wp-config.php file:

define( 'FS_METHOD', 'ftpext' );

If you set it to ftpext or ftpsockets, you also need to add your FTP account login credentials.

You can either add the FTP login information to the wp-config.php file directly or use a plugin such as FTP access that will do the same.

define( 'FTP_BASE', '/path/to/wordpress/' );
define( 'FTP_USER', 'username' );
define( 'FTP_PASS', 'password' );
define( 'FTP_HOST', 'ftp.example.org' );
define( 'FTP_SSL', false );
ConstantsExplained
FTP_CONTENT_DIR The full path to the wp-content folder of the WordPress installation.
FTP_PLUGIN_DIR The full path to the plugins folder of the WordPress installation.
FTP_BASE The full path to the “base”(ABSPATH) folder of the WordPress installation.
FTP_USER Your FTP or SSH username.
FTP_PASS The password for the username entered for FTP_USER. If you are using SSH public key authentication this is not required.
FTP_HOST The hostname:port combination for your SSH/FTP server. If the default FTP port 21 or SSH port 22 is used, this setting is not required. Set port only when using a custom port.
FTP_SSL Used for “Secure FTP” not for SSH SFTP, set to true to use an SSL connection or false to not use SSL.
FTP_PUBKEY The full path to your SSH public key.
FTP_PRIKEY The full path to your SSH private key.

Or if instead of passwords you are using key-based authentification:

define( 'FS_METHOD', 'ftpext' );
define( 'FTP_BASE', '/path/to/wordpress/' );
define( 'FTP_USER', 'username' );
define( 'FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub' );
define( 'FTP_PRIKEY', '/home/username/.ssh/id_rsa' );
define( 'FTP_HOST', 'ftp.example.org' );
define( 'FTP_SSL', false );

If you moved the wp-content or plugins folders to another location, then you can also set paths to those folders:

define( 'FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/' );
define( 'FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/' );

FS_METHOD ssh2

To use FS_METHOD ssh2 for upgrades, you need to add the following to wp-config.php file:

define( 'FS_METHOD', 'ssh2' );

There are two methods for usig the ssh2 for upgrades, forst is to use a free WordPress plugin: SSH SFTP Updater Support:

The second is to use the built-in SSH2 upgrader, which requires the pecl SSH2 extension be installed. If the extension is not enabled for your PHP version, ask your hosting provider to enable it.


Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended