LAMP and default file permissions when apache2 create files

Tags:

Answer: 1

31 hours ago

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

I currently have to run

#!/bin/sh
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

Answer: 2

14 hours ago

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 [email protected]
<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
</Directory>

<IfModule mpm_itk_module>
AssignUserId username username
</IfModule>

</VirtualHost>

and run

sudo service apache2 reload

and everything worked as intended.

Added by: Arianna Zieme

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9