I have setup CentOS on a box on my local network and installed httpd, PHP, Webmin (and UserMin) etc. I opted for ProFTPd and have opened up ports for FTP, Webmin and Apache.

I can now access Webmin over the local network and view the default apache test page. I can also make an sfpt connection as the user I created. However I cannot write files to /var/www/ over FTP.

What do I need to do in order to enable one or more users access to the relevant directory?


While L.D.James' answer (no longer here) put me onto the whole users and groups issue it was not wholly helpful. Thankfully it was enough to get Google involved. Here are the steps I took to solve the problem.

The folder was owned by root which would not be a good group to add a user to. The solution was to create a special group. I called it "www" because I'm inventive like that. Then to move the html folder to that group.

<user> is the username for the user on my system

  1. su to root (or use sudo on every line)
  2. groupadd www (Make group)
  3. usermod -a -G www <user> (Add the user to the group)
  4. navigate to /var/www/
  5. chgrp www html (set the folder to the group)
  6. chmod g+rwx html (allow group access to folder - see also http://ss64.com/bash/chmod.html which was quite helpful)

Result I can now upload files and could have other users also do so should I wish to.

  1. At some prompting I have also set Apache to run as the www group.

This is done by setting the environmental variables (the exact location of which differs depending on flavour of Linux).

Despite other answers the correct way to do this is:

export APACHE_RUN_USER=www

The above assumes that I have also created a user called www whereas because this is a dev box on my desk I am happy for Apache to run as root for now.

Found out about setting apache's user and group via: What user should apache and PHP be running as? What permissions should /var/www files have?

  • I did not see the expansion to your answer (possibly because it is fairly new). What is the security risk of not setting these vars? (which I will set once I find them). – Matthew Brown aka Lord Matt Oct 12 '14 at 22:06
  • 1
    Setting the variable is a way to set the user and group, but a more proper way would be to use the httpd.conf directives (httpd.apache.org/docs/current/mod/mod_unixd.html#user ). You might consider visiting the actual Apache support site and learning about directives ( httpd.apache.org/docs/2.4/mod/directives.html ). By the way, notice what the Apache developers says about setting the user/group to root. it's clear you got your information from a question posted by a novice rather than from an answer provided by an expert. – L. D. James Oct 14 '14 at 9:41
  • The whole thing has mostly been some-what educated guess work for me. I guess it shows. – Matthew Brown aka Lord Matt Oct 14 '14 at 17:09
  • Yes. It does show. As for me, none of my answers, suggestions, or comments were guess. They were all from years of experience and research. My domain, apollo3.com is one of the worlds first web presences. It went up in 1993. – L. D. James Oct 18 '14 at 8:37

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.