views:

2506

answers:

3

Hi. I moved from a shared hosting to a VPS a few weeks ago and I'm having these annoying permission issues with WordPress. You know you can download and upgrade plugins (and wordpress itself) from the admin panel, but since I moved it started asking me my FTP credentials, which is kinda slow when I have to update ~20 plugins.

I think this should be some kind of rights issue. I looked that the shared hosting wordpress files, they all belong to the username and group kovshenin (kovshenin:kovshenin) and the files are -rw-r--r-- and the directories are drwx-r-xr-x.

On my VPS apache runs under apache:apache and my files are kovshenin:kovshenin. What should I do to make them readable and writable by both kovshenin and apache?

Also, I changed the permissions to 0777 for all files and folders of my wordpress installation, that allowed me to install and delete plugins without FTP, but when I pushed to automatic upgrade to WordPress 2.8.1 it still asked me for my FTP account. Is that a wp issue or did I miss something?

Thanks.

Update: I managed to run id and id www-data on the MediaTemple shared hosting. User kovshenin is in group kovshenin, and www-data is in group www-data. No more groups. What's the trick?

Another update Okay, I added the apache user to the kovshenin group, my wordpress files are kovshenin:kovshenin with rw-rw-r-- permissions and drwxrwxr-x permissions on directories, but something is still wrong. The user apache can access the files and folders, I can use the online Themes and Plugins editor in the wordpress admin panel, I'm able to make changes to the .htaccess file from within wordpress, but plugin/theme installation still asks me for FTP credentials!

Any ideas? Thanks.

+2  A: 

You can give ownership to www-data according to here.

Run the following command in your WordPress directory (sudo required):

sudo chown -Rf www-data *

Works for Apache.

KahWee Teng
That works fine, but then I can't edit those files with my regular user and this is what freaks me out.. :(
kovshenin
Are they not still group owned by kovshenin? You ought to be able to still edit them if they are.If not then you could try making the user kovshenin a member of the group that they are owned by and use newgrp to change your group to that before editing them.
Troubadour
They are group owned by kovshenin, but new files which I'll upload from the user kovshenin will become kovshenin:kovshenin and I'd have to chown again. I'm setting up the hosting for a few clients of mine and I'd like their files to be kovshenin:kovshenin style, not apache (or www-data). I wonder how MediaTemple did that..
kovshenin
You can add your regular user to the www-data group or you could also append sudo in the beginning of your command.
KahWee Teng
What command? Please read what I'm trying to do, it's not that simple.. There are no additional groups.
kovshenin
caf has an answer that you want.
KahWee Teng
+4  A: 

What should I do to make them readable and writable by both kovshenin and apache?

  • Create a new group, say "wordpress".
  • Add both koveshenin and www-data users to the wordpress group.
  • Change the group owner of all the files to wordpress (using chgrp).
  • Make sure all the files are group writeable.
  • Set the g+s (setgid) permission bit on all the directories of interest.
  • Make sure kovshenin and apache's default umask includes group read & write permission.

The second last step is the trick. It means that whenever kovshenin or apache creates a file in those directories, the group owner will be set to wordpress (instead of kovshenin or apache).

caf
Okay this is closer, thanks so much, but how come the user www-data and kovshenin on the Media Temple shared hosting account don't have additional groups? What's that trick called? ;)
kovshenin
Hard to say, but the shared hosting account might be set up using phpsuexec.
caf
Okay caf, will check that out, thank you.
kovshenin
Hey there caf, one more question. I changed the group owner of all the files and dirs in the wp folder to apache, the owner is still kovshenin, so it's kovshenin:apache and the rights are 0775, so both kovshenin and apache have rights to read write and execute files. Works fine. I did the g+s part, new files are created with kovshenin:apache, all fine, BUT, the rights for the new file are 755. How do I fix that for 775? Tried settings g+ws.. Doesn't seem to work. Any ideas?Thanks once more.
kovshenin
Oh, sorry, that must be the umask.. =)
kovshenin
Yes, your umask is probably 0022, you need to set it to 0002. By the way, kovshenin doesn't even need to be in the 'apache' group for this to work.
caf
Could you elaborate a bit on how to set the umask ?I'm running Debian and I've tried setting it in .bashrc for the user, however to no avail.
Steffen
@Steffen: Setting it in `.bashrc` will work for normal user accounts; for `apache` started from `init.d`, you can add a line setting the umask in `/etc/default/apache2`.
caf
I'll try that out, thanks.Just one more question: setgid - is it a command or ? I tried typing setgid on Debian, and it didn't know it (could find anything through apt either)
Steffen
@Steffen: The "setgid" bit is a file permissions bit - so it's set by `chmod`. In particular, you want `chmod g+s` on the directories of interest.
caf
@caf: Aaah excellent, then I get it :-)Well I'll give it a try tonight, thanks alot for the elaboration.
Steffen
I've gotten most of it to work, though I still have no luck with automatic updates in wordpress.All files 775 (chmod), the owner is my user, and the group is wordpress. Furthermore I setup my users default group to be wordpress, and set g+s on all directories (and files I think, just did a * :-D)Files are however still created with 644 rights, so my umask isn't in effect I guess.Anyway that's a minor issue, what's more important is that wordpress still asks for FTP access. Could it perhaps be that wordpress must be the owner of the files ? (chown)
Steffen
@Steffen: If wordpress isn't the owner, the files will have to be 644 (and the directories 2775).
caf
@caf: what's the first 2 in the directories ? I always thought there was only owner group guest ?Anyway all files and directories are 775 already.
Steffen
Oh well I give up on it now, I'll just settle on FTP access to update, at least that works out of the box :-D
Steffen
A: 

I had the same problem and I solved it turning off PHP 'safe_mode' in plesk, now WP can create folders and move files without any problems.

I hope this help you.

Fede