-2

I want to set 777 permissions to all new files and folders inside apache2 /var/www/html/apps/

When I extract zip file or create new file, I give 777 permissions via terminal, but this process needs to be done every time. Therefore, I am looking for a solution to make it permanent.

I tried below commands, as per old post URL but not working.

URL => Grant permission for new created files inside folder automatically

getfacl /var/www/html/apps/

setfacl -m "u:zohaib:rwx" /var/www/html/apps/

setfacl -m "o:rwx" /var/www/html/apps/

sudo chmod -R 777 /var/www/html/apps/

Any idea?

Best Regards, Zohaib

6
  • 1
    "Any idea?" Yeah 1... -NOT- a good idea.
    – Rinzwind
    Oct 24, 2019 at 10:24
  • 2
    @Rinzwind I was writing the same thing, 775 would be better, notably blocking virus execution
    – damadam
    Oct 24, 2019 at 10:25
  • I want to install magento and other php open source softwares, they require 777 for development on local machine for some folders Since I am not running live website therefore I think it will be fine. Any idea about 755 permanent permission. Oct 24, 2019 at 11:18
  • @shahab No they do not. devdocs.magento.com/guides/v2.3/cloud/before/… where does it say it requires 777 for development?
    – Rinzwind
    Oct 24, 2019 at 12:25
  • 1
    777 is bad, do not use it for default options or permissions!
    – Thomas Ward
    Oct 24, 2019 at 13:35

1 Answer 1

2

The correct way to set up a webserver is to set the user and the group of files to the user and group you set up the webserver with. You will find a ...

User {user}
Group {group} 

inside the apache configuration file as an example. The default, for apache, is likely www-data. Other webservers will have a similar method. You can match your files with this user and group with:

sudo chown -R {user}:{group} /var/www/

where {user} and {group} need to match those from the configuration. Magento uses the apache user and group but you need to set it up manually.

chmod should not be needed to set up apache and if you need to use it it is more likely an indication something else is wrong.

A method to set up your directories and files inside /var/www/html/ that has the highest possible needed permissions for a correctly working webserver are:

find /var/www/html/ -type d -exec chmod 750 {} \;
find /var/www/html/ -type f -exec chmod 640 {} \;
  • -d means directory, -f means file.
  • 1st digit: "user" should be able to do whatever is need.
  • 2nd digit: "group" can be set to 0 stricly speaking.
  • 3rd digit: "others" have nothing to do inside your website.

Please take security serious when using a webserver.

1
  • thanks for details friends. sorry Magento do not need 777 but I was giving on my local apache2 server on ubuntu. Oct 24, 2019 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .