WordPress: Store FTP access in wp-config.php

Store FTP data for WordPress in wp-config

Most hosters have configured the web space in such a way that you can update plugins and WordPress itself with one click. However, this only works if the web user has enough rights to change files on the server.

In rare cases, however, I have customers with hosting who want the connection data for every update. This is because the security settings on the server are set so high that the web user does not have sufficient rights to install updates.

You usually get this message if the web server is configured in such a way that you cannot perform WordPress and plugin updates from the admin area.
You usually get this message if the web server is configured in such a way that you cannot perform WordPress and plugin updates from the admin area.

Simple solution: "FTP Access" plugin

The option that will probably cause you the least work is the WordPress plugin "FTP access“. However, I would recommend you to enter the data directly in the WordPress configuration file.

On the one hand because you use one less plugin and on the other hand because you never know if and how long the plugins will work. But if you are in a hurry, feel free to test the plugin.

Alternative: Connection via FTP client

The connection data that is meant is the FTP access data, which is usually used to connect to the server via an FTP client such as Cyberduck or Transmit in order to upload the data from WordPress or the plugins.

Of course you can also do all updates in this way, but it is very cumbersome. That is why WordPress offers that you enter the data online on the website. But even that is cumbersome because you have to search for and enter this data again and again.

In the main directory of your WordPress installation you will find the WordPress configuration file (screenshots: Sir Apfelot).
In the main directory of your WordPress installation you will find the WordPress configuration file (screenshots: Sir Apfelot).

Best solution: Store FTP data in wp-config.php

From my point of view, the most practical solution is to enter the access data in the configuration data wp-config.php, which can be found in the main directory of the WordPress installation.

In order to be able to make the corresponding changes there, you have to use the FTP program again or a plugin like "File Manager" to install.

In any case, I recommend you to create a backup of wp-config.php, because if there is an error there, your entire WordPress site will no longer work.

In the text editor you can see where you can enter the lines for the FTP access data, for example.
In the text editor you can see where you can enter the lines for the FTP access data, for example.

Attention: There is an error in the screenshot. In the line with the option "FS_METHOD" you have to enter "ftpext" instead of "direct"! It is correct in the code below.

This is how you enter the FTP data

If the file is open, you can copy the following lines into the file (anywhere after "

define('FTP_HOST', 'ftp.example.org');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_SSL', false);

define('FS_METHOD', 'ftpext');

If your server only offers FTP with encryption (SFTP), then you must enter "true" instead of "false" for FTP_SSL.

Once the file has been updated, you can try out directly whether an update runs without entering the access data and without errors.

All FTP options for wp-config.php

If your server requires other data, you can also find a complete set of the possible options here:

define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/path/to/wordpress/');
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');
define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'ftp.example.org');
define('FTP_SSL', false);

Specification of the port

Some server operators are such security fanatics that they even change the port through which SFTP works. In this case, there is no separate line in the file to enter the port.

Instead, you append the port to the server address. For example, "ftp.example.org" becomes "ftp.example.org:22" - where 22 makes no sense since it is the default port for SFTP.

I hope you get rid of those annoying questions about the FTP connection information. It has always worked that way for my clients.

If you get stuck somewhere, please write me a comment.

Did you like the article and did the instructions on the blog help you? Then I would be happy if you the blog via a Steady Membership would support.

Post a comment

Your e-mail address will not be published. Required fields are marked with * marked

In the Sir Apfelot Blog you will find advice, instructions and reviews on Apple products such as the iPhone, iPad, Apple Watch, AirPods, iMac, Mac Pro, Mac Mini and Mac Studio.

Specials