1

My Magento site is down and I see

main.CRITICAL: Cannot write to the "/var/www/html/var/debug/db.log" file. Unable to write {"exception":"[object] (Magento\Framework\Exception\FileSystemException(code: 0): Cannot write to the \"/var/www/html/var/debug/db.log\" file. Unable to write at /var/www/html/vendor/magento/framework/Filesystem/File/Write.php:54)"} []

I tried php bin/magento setup:di:compile but I get

Command line user does not have read and write permissions on generated directory. Please address this issue before using Magento command line.

I tried changing the permission of generated directory by sudo chmod 0777 -R generated but still no success. Any advice would be great help.

Update : These are the owners of var/log and generated directory

/var/www/html# ls -la var/log generated
generated:
total 16
drwxrwsrwx  3 ubuntu www-data 4096 Apr  6 06:29 .
drwxr-xr-x 22 ubuntu www-data 4096 Apr  6 08:42 ..
-rwxrwxrwx  1 ubuntu www-data  126 Jan 19 20:01 .htaccess
drwxrwsrwx  2 ubuntu www-data 4096 Apr  6 10:43 code

var/log:
total 436820
drwxrwsr-x  3 ubuntu www-data      4096 Mar 17 05:58 .
drwxrwsr-x 12 ubuntu www-data      4096 Apr  6 07:56 ..
-rw-rw-r--  1 ubuntu www-data      7180 Feb  2 13:55 4-1549115600.log
-rw-rw-r--  1 ubuntu www-data       409 Feb  3 11:27 Amasty-inventory-19-02-03.log
-rw-rw-r--  1 ubuntu www-data   1352583 Apr  3 14:00 cache-warmer.log
-rw-rw-r--  1 ubuntu www-data    793265 Apr  3 14:45 connector.log
-rw-rw-r--  1 ubuntu www-data 405626880 Apr  6 10:51 debug.log
-rw-rw-r--  1 ubuntu www-data   8498179 Apr  6 06:23 exception.log
drwxrwsr-x  2 ubuntu www-data      4096 Feb 24 13:49 firebear
-rw-rw-r--  1 ubuntu www-data    483328 Apr  6 10:51 magento.cron.log
-rw-rw-r--  1 ubuntu www-data     36864 Apr  6 10:51 setup.cron.log
-rw-rw-r--  1 ubuntu www-data         0 Feb 10 13:19 shippingaddress_process.log
-rw-rw-r--  1 ubuntu www-data  30228480 Apr  6 10:51 system.log
-rw-rw-r--  1 ubuntu www-data         0 Feb  2 09:39 update.cron.log
-rw-rw-r--  1 ubuntu www-data       870 Mar 19 10:15 update.log
9
  • you need to give file and floder permission to that magento root floders Commented Apr 6, 2019 at 8:52
  • Error is about /var/www/html/var/debug/db.log so You can change permission of this file or apply all permissions from prabhakaran7 answer, this should help also.
    – BartZalas
    Commented Apr 6, 2019 at 9:11
  • @BartZalas I have given 777 permission to db.log file but it did not helped Commented Apr 6, 2019 at 9:44
  • What user do you use to login to the console? You should use user ubuntu to run magento commands in your case
    – BartZalas
    Commented Apr 6, 2019 at 12:38
  • From which user are you trying to execute setup:di:compile command. The issue seems to be with ownership. Commented Apr 7, 2019 at 7:34

3 Answers 3

0

I recommended to try this answer

https://magento.stackexchange.com/a/251718/73525

i hope this will helpful.

4
  • no this is not helping Commented Apr 6, 2019 at 9:08
  • tried all the commands, still no success Commented Apr 6, 2019 at 9:41
  • which os your using Commented Apr 6, 2019 at 9:42
  • using windows and my magento is hosted on linux ubuntu Commented Apr 6, 2019 at 10:14
0

I used the below commands and it solves my issue every time.

php -f bin/magento setup:upgrade
rm -rf pub/static/*
rm -rf var/view_preprocessed/*
php -f bin/magento setup:static-content:deploy
php -f bin/magento cache:clean
php -f bin/magento indexer:reindex
cd ..
chmod 777 -R html
0

I got the same problem, the following solved:

sudo chown <user> -R *

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.