Troubleshooting Apache/PHP 500 error

Jephe Wu -

Problem: apache access log shows 500 error code whenever accessing a PHP page which should be prompted to download a docx file.
Environment: CentOS 5.6 64bit, Apache httpd 2.2.3, PHP 5.2.10 from centos test repository

Troubleshooting steps:

1. When problem happens, browser doesn't show anything, only apache access log files shows 500 error code which indicates some sort of issues.

2. Since it's php page, we need to enable error reporting in /etc/php.ini(centos) or /etc/php5/apache2/php.ini(ubuntu). The following is for enabling error reporting.

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = On

This way, we can see some kind of error showing on the screen when we access that php page. Here is the error showing on the screen after enabling that:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /var/www/xxxx/xxxxxx.php on line 297.

3. check memory limit in /etc/php.ini

root@reports01:/etc/ # cat php.ini  | grep memory
memory_limit = 256M; Maximum amount of memory a script may consume (256)

Actually, 67108864 bytes is exactly 64M, which is not 256M that indicated in php.ini.

4. find out where 64M is defined in the php code

root@reports01:/var/www/docgen# grep 64M * -R
lib/header.php:ini_set('memory_limit', '64M');

5. remove that line in php code, problem solved.

1. how to use php 5.2 for CentOS 5.6?

2. PHP 5.2 on Ubuntu 10.04 Lucid Lynx