I have a CentOS VPS. The problem is my html files in /var/www/html seem to need to be owned by the apache user in order for some web applications to work (ie file uploads). If they are owned by the apache user, the web apps work but my ftp user no longer has access to the files. If they are owned by the ftp user, then the web apps stop working again.

What can I do to solve this? The only temp solution for the moment is keep them owned by the ftp user and give the directories 777 that need file uploads. I understand that this isn't secure though?

CentOS is setup with the default Apache config. FTP is proftpd and my user is in an ftpusers group.


You can use groups.

  1. Add your FTP user and apache user to the same group.
  2. Grant the new group enough privileges to the files/folders.
  3. Change the group owner of the files/folders to be the new group.

It is recommended to change the primary group of the user using the command:

$ sudo usermod -g newgroup user

Other groups can be added using -a -G options. Also, the new group will not be seen in the current shell, you can to logout and login again.

| improve this answer | |
  • I've done (1), then when I do chown -Rf ftpuser:webfilesgroup, the problem still exists, even with 775 on the directories. They still need 777 to be "writable" by the web app – ServerBloke Feb 7 '12 at 11:53
  • You need to check the full path permissions not just one file/folder. Make sure your FTP user and apache user are members of your group webfilesgroup using the groups command. – Khaled Feb 7 '12 at 12:30
  • They are in the group. What do you mean by full path perms? Should I set 775 on /var, /var/www, /var/www/html ? – ServerBloke Feb 7 '12 at 12:37
  • 1
    @John: Have another look at the answer. – Khaled Feb 7 '12 at 13:26
  • I added both users to the group using -a -G, are you saying I should set their primary group to the webfilesgroup? – ServerBloke Feb 7 '12 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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