Wordpress | Save FTP Information and Credentials for Updates

If you maintain a WordPress site it maybe asks you to provide FTP details before upgrading itself or upgrading plugins. Here I will explain how to get ridge of this message and why it appears only on some hosts.

The cause of the FTP problem

This "problem" depends on the web server (host) you are using to  provide your WordPress web site. As Joost De Valk stated out correctly:
Filesystem access is available, the files are owned by me, but the web-server doesn't run as me, and thus, WordPress doesn't detect the automatic update correctly.

The core of the problem is the mode the web server is running the WordPress scripts and how the owner of the files and directories are set. For example: If the host is using Apache as web server the server that is doing the work runs as the apache user 'www-data'. By default, this user does not the correct access to your web directories to write files.

If the server is running in a special mode like PHP with FastCGI. It will be able to execute the scripts with the correct user and no problem with writing the needed files appears for the user. So it is more a web server administration problem than a real WordPress problem.

The solution of the FTP problem

The presented solutions are based on editing the WordPress default configuration file wp-config.php. This file can be found inside your WordPress installation directory on your web server.

Updating without a FTP connection for Wordpress

If you putt the following line to the end of your wp-config.php file it will avoid the usage of the ftp connection and directly install the update:
define(‘FS_METHOD’, ‘direct’);

But be warned! As stated out by this Stackoverflow Thread it can be a security risk to use this kind of configuration.

Updating by proving the FTP information for Wordpress

Its annoying that there is no front end option to save these FTP connection as default to use. However you are able to force WordPress to save your FTP connection information and credentials like Host, username and password as defined by the WordPress Codex. For me it was enough to put the following lines to the end of your wp-config.php file:
define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'host');
define('FTP_SSL', false);
{{ message }}

{{ 'Comments are closed.' | trans }}