So certain sites on my server have been through a nice string of phishing attacks lately. The vulnerability they've been exploiting was the fact that some directories where chmod 777 (for file uploads). So since I can't use 777 for those directories, what CAN I use to let me (and other uses) upload files. I've tried 755 and 766 but get a Permission Denied error from my PHP code.
You could use 776 I suppose. That would give users and root write access but not to guests. Or maybe 774.
try chown user.group filename This will allow you to change the file without letting anybody else do so