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.

All the files in my WordPress path are owned by myuser:www-data and Apache is running as www-data. All files and folders have group write permissions, e.g. -rw-rw----, but I keep being prompted for FTP details when I try to install a plugin.

If I chown the path to the www-data user, plugin installation and deletion work as expected, but then myuser cannot edit files. I could add myuser to the www-data group, but then myuser could access all other sites.

My files are chown'ed as follows:

chown -R myuser:www-data wordpress-folder/*

And chmod'ed as follows:

find wordpress-folder/ -type d -exec chmod 755 {} \;
find wordpress-folder/ -type f -exec chmod 644 {} \;

If my files are owned by the www-data group and are group-writable, then surely WordPress should be able to install plugins. Why can't WordPress install plugins?

Here is the output of ls -la in my plugins folder:

total 48
drwxrwx---  9 myuser www-data 4096 Aug  5 01:26 .
drwxrwx---  6 myuser www-data 4096 Aug  5 01:51 ..
drwxrwx---  6 myuser www-data 4096 Jul 10 16:27 disqus-comment-system
-rw-rw----  1 myuser www-data 6148 Jul 10 15:37 .DS_Store
drwxrwx---  7 myuser www-data 4096 Jul 10 16:30 gravityforms
-rw-rw----  1 myuser www-data   30 Jul 10 15:37 index.php
drwxrwx---  3 myuser www-data 4096 Jul 10 16:30 lime-export
drwxrwx---  6 myuser www-data 4096 Aug  1 11:17 mp6
drwxrwx---  6 myuser www-data 4096 Aug  5 01:26 rewrite
drwxrwx--- 10 myuser www-data 4096 Jul 10 16:38 wordpress-seo
drwxrwx---  7 myuser www-data 4096 Jul 24 17:14 wp-minify
share|improve this question
add comment

1 Answer

I think, I've answered a similar question here before. OP claims all file permission are set correctly but still ask for ftp credentials.

Well, this is very weird. But I think, it is still about permission.

Wordpress will write a temp file and compare the file owner by getmyuid() == @fileowner($temp_file_name).

If ture, it'll install the plugin directly without asking ftp details.

For more details, wp-admin/includes/file.php and get_filesystem_method function.

So, I would suggest you, write an independent php script in the root folder of wordpress installation to check out.

1, write a temp file

2, check the owner of the temp file

$dir = dirname(__FILE__);

$temp_file = $dir.'/wp-content/'.time();
$temp_handle = fopen($temp_file, 'w');
if ( $temp_handle ) {
    if ( getmyuid() == fileowner($temp_file) ){
        echo 'file owner correct';
    }

    fclose($temp_handle);
    unlink($temp_file);
}else{
    echo 'cant write file';
}
share|improve this answer
    
Maybe my default permissions are wrong? I'll check. –  pate Aug 5 '13 at 2:13
    
So WordPress is checking the result of getmyuid(), which should be www-data against the owner of a newly created file, which would be myuser, not www-data. Looks like the only way this would work without modifying WordPress code is to chown everything to www-data, or to run Apache under myuser. Any ideas? –  pate Aug 5 '13 at 2:25
    
You may want to run Apache under myuser rather than hacking wordpress core php –  Jesse Aug 5 '13 at 2:29
    
It gets weirder. If I put that code in a PHP file and run it under my WordPress folder, it works and I can output the result of getmyuid() and the temp file owner both as 33 (for www-data), so I should not be prompted for FTP details. –  pate Aug 5 '13 at 2:45
add comment

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.