I installed Wordpress locally to try out private blogs and feeds. When trying to install the Members Only plugin, I got the following message:
Connection Information
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.
FTP is totally 1990, and I only have SSH access on my machine. So what is causing this error?
It turns out the message is coming from wp-admin/includes/file.php, function get_filesystem_method which tries to detect if wordpress can write files.
A temporary file is created, and the owner of that newly created file is compared with the owner of file.php - if they match, wordpress assumes direct access. If they are not the same, wordpress requests FTP credentials.
Groups
I had assigned the wordpress folder to the www-data group, and given group write rights to all files in it. But since Wordpress only compares the owner, it still required FTP credentials.
Since I was probably not the first one to notice that I searched the bug reports, and found some relevant ones:
- #33966: Wordpress file ownership.
- #10205: getmyuid() called instead of posix_getuid() in get_filesystem_method() (wp-admin/includes/file.php)
The latter gives the reason why group write rights are not used:
Group-writable is not supported currently.
The owner on new files can never be set correctly, so it'll always be owned by the web server (ie. apache) instead of by the current user.
Thats why it checks the owner of the current file, compared to the owner of created files.
I'm closing as wontfix, due to the ownership issues. It could cause huge problem on some shared hosters (most of the major ones at least).
Workaround
So what should I do now? I don't want to chown the files.
It turns out that you can circumvent the file system detection by setting a FS_METHOD constant in wp-config.php:
define('FS_METHOD', 'direct');
With that, Wordpress does not autodetect if it has access but simply tries writing files directly.