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
Raj Mohan R
  • 2,048
  • 1
  • 8
  • 13

3 Answers3

0

I recommended to try this answer

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

i hope this will helpful.

prabhakaran7
  • 1,077
  • 1
  • 16
  • 58
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 *
IndexError
  • 11
  • 3