Fixing OpenCart missing openbay.log file

Updating the DIR_STORAGE path in the config.php is the easiest means of fixing the missing openbay.log for OpenCart

Recently, my personal blog and demo site of OpenCart went down due to a database connection error.  I wasn't sure if it was a hack or not since there was no evidence of such an act. I checked Apache2 log files for information about the error. Not much information was given. Therefore, I did the unthinkable and deleted all the Apache2 error log files and restarted Apache2. My blog was back up, but the OpenCart demo site was showing the following error:

Warning: fopen(/path/to/opencart/storage/logs/openbay.log): failed to open stream: No such file or directory in /path/to/opencart/system/library/log.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in /path/to/opencart/system/library/log.php on line 39

At first, I thought it was caused by deleting the soft linked file, but after inspecting the directory for OpenCart log files, I released that the path was incorrect. I'm not sure why. However, I updated the config.php in the based of the OpenCart folder with the correct path for the 'DIR_STORAGE'. Funnily, the config.php file inside the admin folder had the correct path. At that point, I started to ponder about if I was really hacked. However, there's no evidence to back this claim, so the best thing I did was to ensure no one can access the config file apart from root.

sudo chown root:root config.php
sudo chown root:root admin/config.php

I even went to the extent of adding a block command to the .htaccess file:

RewriteRule ^(admin/config\.php|config\.php) - [F,L,NC]

Interestingly, the guys over at White Fir wrote a blog post describing a similar issue. However, they took a different approach to fix the issue by creating the given log folder seen in the error message.   In summary, the problem was fixed by updating the directory path in config.php file, but the cause of why the path was incorrect for the root config.php is unclear.

Update on the database connection error

As mentioned earlier, I was getting a database connection error for my WordPress blog. After I removed the log files, restart the server and fixed the OpenCart error, I thought everything was working. However, a few minutes later, I got was notified by Jetpack that my site is down. When I checked, I saw the same renowned database connection error. I started to research and troubleshoot the server only to realize that MySQL was blocked due to a lock on its socket. I couldn't even log into MySQL from the command line. I was getting the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I tried countless of fixes that issuers have suggested but none of them worked. I even went to the point of uninstalling and reinstalling MySQL, but that still didn't work. Thankfully, I'm running my blog on a dedicated server, which I restarted on my host provider dashboard. It's back up and running smoothly.

Go Back