Where can I change the default file permissions that apache2 set for a file when its created or edited ?

I currently have to run

chown -R username:www-data .
find . -type f | xargs chmod 664
find ./bin -type f | xargs chmod 775
find . -type d | xargs chmod 775
find . -type d | xargs chmod +s
umask 0002

to fix my file permissions, after Apache2 have created a file.

all my files in /var/www/html need to have this permissions set up:

drwsrwsr-x  2 username www-data 

for everything to work smothly

But all files created by apache have this permission set up:

drwxr-sr-x 2 www-data www-data
  • Note: This is a dev server, so security at this point is not the highest priority. I use the box for learning, and its accessible only locally. But if I do something wrong in my approach, then a heads up is appreciated

My solution to this problem, was to set up a viritualhost for my domainname. whit mpm_itk_module Enabled.

My etch/apache2/sites-enabled/domain.conf file looks like this:

ServerAdmin admin@email.com
<VirtualHost *:80>
ServerName domainname.com
ServerAlias domainname.com
DocumentRoot /URL/TO/HOME/username/public_html
<Directory /URL/TO/HOME/username/public_html/>
        AllowOverride All
        Require all granted

<IfModule mpm_itk_module>
AssignUserId username username


and run

sudo service apache2 reload

and everything worked as intended.

| improve this answer | |

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.