cancel
Showing results for 
Search instead for 
Did you mean: 

File and folder permissions

SOLVED

File and folder permissions

Hi,

 

I want to know how to set the correct permision in production shop (Magento2), and i want to know how to set it by the terminal, like:

sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 755 {} \;

sudo find ./var -type d -exec chmod 777 {} \; 

sudo find ./pub/media -type d -exec chmod 777 {} \;

sudo find ./pub/static -type d -exec chmod 777 {} \;

sudo chmod 777 ./app/etc

sudo chmod 644 ./app/etc/*.xml
sudo chmod 777 -R var/log

but with the correct ones

1 ACCEPTED SOLUTION

Accepted Solutions

Re: File and folder permissions

I see. That makes sense now. 

As mentioned before, all directories should be 755 and files can either be 644 or 664. 

Magento Certified Solution Specialist | Lead Magento developer
If this response was helpful to you, consider giving kudos to this post

View solution in original post

7 REPLIES 7

Re: File and folder permissions

@HHFFPP

 

Answer to your question is here on this link: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html 

 

Alternatively, copy/paste the following code if you don't want to click the link. 

cd <your Magento install dir>
find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
chmod u+x bin/magento

To optionally enter all commands on one line, enter the following assuming Magento is installed in /var/www/html/magento2:

 

cd /var/www/html/magento2 && find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento
Copy

 

Magento Certified Solution Specialist | Lead Magento developer
If this response was helpful to you, consider giving kudos to this post

Re: File and folder permissions

but If i have one permissions setted before, the chmod u+w don't change it, its the reason i prefer the solution with the number, chmod 644, for example.

Re: File and folder permissions

@HHFFPP

 

It'd change the permission and apply the Magento suggested permissions to your who Magento system.


It's important to follow the Magento guidelines to setting up the system otherwise you're at a risk of getting hacked. However, if you'd still want to stick to your custom permissions then you can always apply them on manually. 

Magento Certified Solution Specialist | Lead Magento developer
If this response was helpful to you, consider giving kudos to this post

Re: File and folder permissions

No, i want to change the permissions, but i play a little with it and now if i apply the one you suggested, it don't change to be more restrictive (i think).

For example, if i had this file:

-rwxrwxrwx ubuntu:www-data blafile.txt

and i executed: chmod u+w blafile.txt:

-rwxrwxrwx ubuntu:www-data blafile.txt

didn't change

it's the correct way when the file is in the default mode. But for me the permissions didn't change.

It's the reason that i need the permission in the 644 format, becaouse it really change the permission:

chmod 644 blafile.txt:

-rw-r--r-- ubuntu:www-data blafile.txt

Re: File and folder permissions

@HHFFPP

 

I'm still lost but if I have understood correctly then you can change rwxrwxrwx to 777 or whatever you need. 

 

As a good practice, all files should either be 664 or 644 and directories should be 755. 


I hope that helps. 

Magento Certified Solution Specialist | Lead Magento developer
If this response was helpful to you, consider giving kudos to this post

Re: File and folder permissions

No, I want to say that i can't change the permision with chmod u+w, i need the numbers, like the first post, but with the correct ones.

For example, i need to know what permission i can put in var directory and subdirectories, maybe:

chmod 755 -R var
chmod 777 -R var/log

or something similar, but for all.

Re: File and folder permissions

I see. That makes sense now. 

As mentioned before, all directories should be 755 and files can either be 644 or 664. 

Magento Certified Solution Specialist | Lead Magento developer
If this response was helpful to you, consider giving kudos to this post