Problem with php and apache

I had the same problem but it was because CentOS (and I assume RHEL), by default, doesn't recognize the short short tag...

<?

but requires the long tag...

<?php

at the beginning of a block of PHP code.

In php.ini (probably /etc/php.ini) look for "short_open_tag = off". Change this to "short_open_tag = on" and restart Apache to allow the short tag.


Make sure your handler looks like in the first reply and make sure it comes after mod_mime - this is most likely a handler issue:

LoadModule mime_module modules/mod_mime.so

Mod_mime is required to actually use the handlers. You should get a warning if it can't find mime.types (a dependency of the above module), but you might do a find / -name mime.types and copy this file into your /etc/httpd/conf/ directory.

http://httpd.apache.org/docs/2.0/mod/mod_mime.html You can make sure it's looking in the right place for the mime types by setting this TypesConfig directory: http://httpd.apache.org/docs/2.0/mod/mod_mime.html#typesconfig

You can also see if you have any luck adding these lines:

AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php

(The Type is more important for client requests.)


A simple test to see if you have PHP with mostly defaulted settings, is to go to a nonexistant page on your server thus generating a 404 error. It should tell you at the bottom something along the lines of

Not Found

The requested URL /test was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.11

Notice the PHP/5.2.11 in this listing....