0

Can someone please advise me on the following problem

Here is a link to a video showing what is happening https://vimeo.com/228143296

I strongly believe this is a permissions problem

In video clip one I do the following steps

  1. In terminal I type in command - php bin/magento setup:upgrade This brings up a warning message in red

(Permission denied in /var/www/html/top-property-store/vendor/colinmollenhour/cache-backend-file/File.php on line 663)

  1. I refresh the page the site is still working

  2. I put in command sudo php bin/magento setup:upgrade

  3. I refresh the site and the site is down with a warning message

In video clip two I do the following

  1. I put in command sudo php bin/magento setup:upgrade

2 I put in command sudo php bin/magento setup:di:compile

  1. Go to the site then click on a link and the site is down again with the same warning

Warning: file_put_contents(/var/www/html/top-property-store/var/cache//mage-tags/mage---cc6_COMPILED_CONFIG): failed to open stream: Permission denied in /var/www/html/top-property-store/vendor/colinmollenhour/cache-backend-file/File.php on line 663

1
  • I looked at the video briefly. You should not need to use sudo if you have access to login or su to become the web server file system user. Otherwise you could try sudo -u <Magento file system owner> <command> ref docs. Else your files will be created with root as owner rather than the web file system owner.
    – jtlindsey
    Commented Nov 10, 2017 at 13:12

4 Answers 4

2

I wouldn't recommend using 777 permissions as this allows global write permissions. In a shared hosting environment i prefer to use :

chown -R webserveruser:webservergroup ./ PATH

If you must use chmod check the official documentation and what it recommends

chmod -R u+w .

https://devdocs.magento.com/guides/v2.0/config-guide/prod/prod_file-sys-perms.html

1
  • I can't believe how much people in other answers are recommending to use 777 permissions... which means a total fateful practice. Kudos for the only answer leading to devdocs, which all users should read one time & another & another until they get what hosting a local Magento2 project means regarding ownership of files & permissions Commented Jun 4, 2019 at 7:24
-1

This is a native thing only. Whenever you compiling the magento, it will generate new classes in /var/generation. Since this is system generated directory you should give 777 permission to the 'var' directory. So assign the 777 permission to the /var every time after finishing the compilation.

1
  • Below is the permissions for var folder taken from terminal drwxrwsrwx 13 apache apache 4096 Aug 4 23:20 var I am not experienced with folder permissions but it does look like /var folder does have 777 permission
    – Ray
    Commented Aug 4, 2017 at 23:27
-1

Please below permission to folders :

sudo chmod -R 0777 var/
sudo chmod -R 0777 media/
sudo chmod -R 0777 app/etc/
-2
php bin/magento cache:flush  
php bin/magento cache:clean  
chmod -R 777 var pub

use these 3 commands, it works for me when I get this same error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.