Cobra Forum

Plesk Panel => Plesk Service/Interface => Topic started by: mahesh on Feb 06, 2024, 02:20 AM

Title: Unable to open the domain's logs in Plesk: PHP Fatal error:
Post by: mahesh on Feb 06, 2024, 02:20 AM
Question:
Unable to open the domain's logs in Plesk: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8192 bytes)
Symptoms
500 error
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8192 bytes) in /usr/local/psa/admin/plib/LogBrowser/Reader/PhpFopen.php on line 105
#ls -lah /var/www/vhosts/system/example.com/logs/
total 31M
drwx------ 2 psaadm root 4,0K dic 24 03:59 .
drwx--x--x 6 root psaserv 4,0K jun 27 16:14 ..
-rw-r--r-- 3 root root 2,1K dic 24 09:22 access_log
-rw-r--r-- 3 root root 3,4M dic 24 03:59 access_log.processed
-rw-r--r-- 3 root root 0 dic 23 05:29 access_ssl_log
-rw-r--r-- 3 root root 51K dic 24 03:59 access_ssl_log.processed
-rw-r--r-- 3 root root 9,8K dic 19 12:19 error_log
-rw-r--r-- 3 root root 27M nov 16 17:51 error_log.1.gz

#zcat /var/www/vhosts/system/example.com/logs/error_log.1.gz | wc -l
20022263

Cause
Due to insufficient PHP memory limit Plesk Log manager fails to process big-sized rotated log files.

Resolution
1.Connect to the server via SSH.

2.Increase the memory_limit value in /usr/local/psa/admin/conf/php.ini using a text editor.

#grep 'memory_limit' /usr/local/psa/admin/conf/php.ini
memory_limit = 512M

Restart Plesk service:

#service sw-cp-server restart
As preventive measure move the old domain logs and enable log rotation by size
1.Connect to the server via SSH.

2.Move old and compressed log files from logs directory with following 3 commands:

#mkdir -p /root/oldlogs/example.com
# find /var/www/vhosts/system/example.com/ -name '*.gz' -exec mv {} /root/oldlogs/example.com/ \;
# find /var/www/vhosts/system/example.com/ -name '*.processed' -exec mv {} /root/oldlogs/example.com/ \;

3.Set the log rotation as instructed on this article, e.g. by size of 5000kb.