Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I upload files through php, it writes the file with the permissions 644 (-rw-r--r--).

I have my /var/www/html folder setup with setgid, so that all files uploaded are set to a group that should be allowed explicit access (FTP, etc). However, 644 permissions do not allow the group of the file to write, which is a problem.

How can I configure apache2, so that all files/directories created by www-data within the /var/www/html folder have the permissions 775 (-rwxrwxr-x) set to them?

I am running Ubuntu 14.04 on a DigitalOcean VM with Apache 2.2.

share|improve this question
up vote 0 down vote accepted

Apache inherits its umask from its parent process (i.e. the process starting Apache). This should typically be the /etc/init.d/{apache,httpd} script. So you can put a umask command in that script.

# echo "umask 002" >> /etc/init.d/httpd

and then:

# /etc/init.d/httpd restart

Or you can also run this command:

# echo "umask 002" >> /etc/sysconfig/httpd

and then

# /etc/init.d/httpd restart
share|improve this answer

You can change the permissions after uploading the file with the php function chmod.

share|improve this answer

Your Answer


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.