Your software
My Mautic version is: 5.2.6
My PHP version is: 8.2
My Database type and version is: MySql
My problem is:
Every morning I find that Mautic has a write permission issue with the folder /var/www/html/mautic5/var/logs/.
I ran the following command:
find /var/www/html/mautic5 ! -user apache -o ! -group apache -exec ls -l {} ;
to check whether all files, folders, and subfolders were correctly assigned to the apache:apache user and group—and they are.
Still, the only way to fix the issue again this morning was to run:
sudo chown -R apache:apache /var/www/html/mautic5/var/logs/
I suspect that Mautic runs some scheduled tasks during the night that alter the permissions of that folder.
I don’t think it’s caused by AlmaLinux itself, as I haven’t configured anything related to that.
Do you have any suggestions or advice on this?
I finally discovered the problem.
I really made a rookie mistake.
The user/group that has permissions on the /var/www/html/mautic5/ folder and its subfolders is apache:apache.
However, I had configured the cron jobs to run as the root user.
And among the various jobs configured, there was this one:
0 2 * * * php /var/www/html/mautic5/bin/console mautic:cache:clear > /dev/null 2>&1
Evidently, the cache clearing job deletes and recreates some folders, and when they are recreated, they are assigned to the root user.
This prevents the apache:apache user from working with them properly.
I fixed it by modifying the command execution as follows:
0 2 * * * sudo -u apache php /var/www/html/mautic5/bin/console mautic:cache:clear > /dev/null 2>&1
Suggestion for the Mautic theme documentation:
I made a rookie mistake, but it might still be useful to clearly state in the Mautic documentation that cron jobs should be executed by the same user that owns the folders managed by Apache.
system
Closed
June 1, 2025, 8:36pm
3
This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.