Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I don't think this is a duplicate, although I've seen similar questions on here.

I have added my primary SSH/FTP user and the user nobody to a group called webserver, then I ran a chown -R .webserver /var/www so that both FTP and Apache would be able to write to the file system.

I know that PHP can write to the server -- I can upload an image using the Media Library. However, when I go to install a plugin, it prompts me for my FTP credentials.

If I add define('FS_METHOD', 'direct'); to wp-config.php, this goes away and plugins install without an issue.

Why would this happen, though? According to the Codex, the preferred method is direct, and it's able to manipulate the file system directly. So what would make it prompt for FTP instead?

Thanks!

EDIT:

I took a look at the source for how it determines what file system method to use (wp-admin/includes/file.php, line 933), and I figured out that it can create a test file, but the owner does not match the processor's UID. Taking a look at the PHP manual for getmyuid() and fileowner($file), it seems that, instead of using getmyuid(), it should be using posix_getuid(). Any idea why the developers would use the former?

EDIT 2:

Noted in WordPress bug tracker: https://core.trac.wordpress.org/ticket/10205

share|improve this question

1 Answer 1

Posix is a PHP extension rather than part of PHP core. WordPress tries to minimize use of extensions as much as possible in its core. In specific case of Posix one — it has very notable flaw of not being available on Windows platform altogether.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.