Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Running PHP 5.3.3 through Apache 2.2.15, on Red Hat (kernel 2.6)

I have a test file in the root directory called test.php:

<?
  phpinfo();
?>

When I point my browser to this file, it sends me this source uninterpreted.

No errors are shown in the log, and the access log has a standard entry:

xx.xx.xx.xx - - [29/Nov/2012:10:26:56 -0500] "GET /test.php HTTP/1.1" 200 17 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.91 Safari/537.11"

My configuration file has the following lines:

/etc/httpd/conf/httpd.conf

...
Include conf.d/*.conf
...

/etc/httpd/conf.d/php.conf

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

No errors are logged at startup, which suggests that the modules are indeed being loaded in correctly.

This is all out-of-the-box configuration, so I'm really surprised this doesn't just work. Any ideas?

share|improve this question

1 Answer 1

Sigh Why is it that, after hours of searching, you find nothing. But then get the answer 2 minutes after posting to SO?

So, whatever site I copied that test file from didn't take into consideration that short tags are off by default. Changing the test file to

<?php
  phpinfo();
?>

fixed everything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.