Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

apache serves php files as text

Status
Not open for further replies.

anorakgirl

Programmer
Jun 5, 2001
103
0
0
GB
hi,
sorry, i'm sure this is a really common question, but i can't seem to resolve it. i've just installed php on a second redhat box, and as far as i can tell i've done everything the same as the first one on which it works, but it doesn't - when i try to request a php file, it just gets served as text i.e. the php isn't processed.

here's what i've checked:
libphph4.so is in the right place

my httpd.conf has the following lines:
LoadModule php4_module libexec/libphp4.so
AddModule mod_php4.c

and later:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

don't get any errors when i start apache or anything, can't think of anything else to check. i'm not even sure how to tell where the problem is, i.e. is apache is loading the php4 module at all, or it it just something in my config file not telling it to parse the files or something.

anyone suggest what i should be checking?
thanks!



~ ~
 
You need to make sure apache knows what type of encoding to use for displaying php.. its in the "add type" section of httpd.conf and should look something like this:
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# For example, the PHP 3.x module (not part of the Apache distribution - see
# will typically use:
#
AddType application/x-httpd-php3 .php3 .php

=========================================================== I can't have sent that email, it says from Superuser.
 
oh and thanks karver, but as i said in my first post, i have the line
Code:
AddType application/x-httpd-php .php
which i think shoud be right for php4... ~ ~
 
OK Try <?php phpinfo(); ?> I can't have sent that email, it says from Superuser.
 
Oddly I had this happen at work when changing extensions for php files.
(We were using .phtml, changed to .php and all you get was code :()
The cure it seems was not restarting apache, but re-booting the server - this made everything work as intended.
Hope this helps. I can't have sent that email, it says from Superuser.
 
thanks for the help all. for info i fixed it by commenting out the following:
Code:
<IfModule mod_mime_magic.c>
    MIMEMagicFile local/apache/conf/magic
</IfModule>
seems that this was interfering with the php AddType line (or something, all seems to work now anyway)

cheers!
~ ~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top