Changed "cache" folder to 777 and error log still shows "Unable to create the "cache" directory"

Your software
My Mautic version is: 5
My PHP version is: 8.0.30
My Database type and version is: MariaDB 10.3.39

Your problem
My problem is: Mautic login page won’t load

These errors are showing in the log:

[Sun Apr 21 01:55:49.652470 2024] [proxy_fcgi:error] [pid 37775] [client 127.0.0.1:44904] AH01071: Got error ‘PHP message: PHP Warning - mkdir(): File exists - in file /var/www/vhosts/domain.com/mautic.domain.com/docroot/app/bundles/CoreBundle/Cache/MiddlewareCacheWarmer.php - at line 57PHP message: PHP Warning: mkdir(): File exists in /var/www/vhosts/domain.com/mautic.domain.com/docroot/app/bundles/CoreBundle/Cache/MiddlewareCacheWarmer.php on line 57PHP message: RuntimeException: Unable to create the “cache” directory (/var/www/vhosts/domain.com/mautic.domain.com/app/…/var/cache/prod). - in file /var/www/vhosts/domain.com/mautic.domain.com/vendor/symfony/http-kernel/Kernel.php - at line 638’

Steps I have tried to fix the problem:

I ran the following ps aux | grep apache2 to see what the apache user is that the server uses, and it matches to what the “cache” folder owner is. I read online that on “almalinux 8.9” the apache user is “apache” but I don’t see that user when I run the above command.

I just got a new dedicated server and I was trying to update from Mautic 2 to Mautic 5. I was able to upgrade properly to Mautic 3 and then Mautic 4 from the website option. Then I following the instructions below to try to update from Mautic 4 to Mautic 5 using “Composer”, but now I’m stuck with the website not loading because of this “cache” folder issue.

https://docs.mautic.org/en/5.x/getting_started/switching_composer.html

Can anyone provide any steps I can take to resolve this issue?

Thank you.

So I ended up installing a new copy of Mautic 5 on a different subdomain, once it installed I just copied over the files to my original subdomain and connected it to the existing DB I was originally using.

This allowed me to finally get the website working and I was able to login to Mautic, however, now I notice some pages just don’t load; for example, “Tags”, “API Credentials”, “Account”, etc. I cleared cache but that didn’t work either.

I then ran the following to migrate any DB issues, and you can see the results in the screenshot image link below.

/opt/plesk/php/8.0/bin/php bin/console doctrine:migration:status
/opt/plesk/php/8.0/bin/php bin/console doctrine:migration:migrate

I just noticed the following error in the logs when I try to go any of those pages that aren’t loading.

500 GET /s/credentials?_=1713713844078&mauticUserLastActive=728&mauticLastNotificationId= HTTP/1.1

Does anyone have any insight on how I can get these pages to load properly? Would this be a DB or Codebase files issue?

Thank you.

I was able to get this to work, for anyone else facing this issue…

I ended up using the “Devart dbForge Schema Compare for MySQL” software to compare the database structures of the fresh install of Mautic to my existing Mautic that had issues. It seems like the database structures weren’t the same even after successfully running the following commands.

/opt/plesk/php/8.0/bin/php bin/console doctrine:migration:status
/opt/plesk/php/8.0/bin/php bin/console doctrine:migration:migrate

I then use dbForge software to synchronize my existing Matic database structure that seemed to fail during my upgrade to Mautic 5 with the fresh installation that I made of Mautic 5.

After doing this my existing Mautic website works properly now and I don’t have anymore issues with pages not loading.

I feel like I’m talking to myself on this support forum, but hopefully this helps someone else going through this issue and can use the steps I took to fix their existing Mautic application when an upgrading Mautic fails.

2 Likes

yup!
it was helpful topice

1 Like

That was helpful - thanks.

Small advice;
Never, under any circumstances, do a chmod 0777

Folders should always be 0755
Files should usually* be 0644

*config file should be 0600 to avoid any group or anyone to read it.

1 Like

Yes, at that time I was just trying different things because I was getting no where in solving this issue. Now that I fixed it and Mautic is running properly, I’ll go back and change the permissions back to what they were before.