LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-21-2007, 01:31 AM   #1
mastahnke
Member
 
Registered: Feb 2002
Location: IL
Distribution: Ubuntu currently, also Fedora, RHEL, CentOS
Posts: 111

Rep: Reputation: 15
Question Apache rending php when filename is x.php.html


I am not sure if this is a bug, or if there is an easy fix, but I am having issues with Apache and PHP.

Here's the problem

I make a file named test1.php
Code:
<?php
  phpinfo();
?>
It spits out normal phpinfo stuff.

I rename that file to test1.php.html and point my browser to this new file.

It still renders as PHP. To me this is a bug. If the final extension is html it should render as text/html and not be passed to the PHP parser.

I am using FC6 if that helps at all. I don't remember seeing this problem on Ubuntu when I was doing something similar, though I am unsure how to force apache to only render based on last extension and not a pattern match.

Any help would be appreciated.
 
Old 01-21-2007, 10:33 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
There is a directive in the apache config where you can set what should be parsed as php. Rename file to test1.html; if it does the same thing, that certainly is what you should change. No apache server at hand to check.

Last edited by Wim Sturkenboom; 01-21-2007 at 10:34 AM.
 
Old 01-21-2007, 10:35 AM   #3
mastahnke
Member
 
Registered: Feb 2002
Location: IL
Distribution: Ubuntu currently, also Fedora, RHEL, CentOS
Posts: 111

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Wim Sturkenboom
There is a directive in the apache config where you can set what should be parsed as php. Rename file to test1.html; if it does the same thing, that certainly is what you should change. No apache server at hand to check.
I realize this. This is the code from /etc/httpd/conf.d/php.conf. I don't see anywhere that says a file named my.php.thing.html should be rendered as php. When I disable PHP all together, of course the behavior is as expected.

Code:
 PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
 
Old 01-21-2007, 11:35 PM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
If I add this line, it parses html files. If I leave it out, it does not parse html files.
Code:
AddType application/x-httpd-php .html
Below the changes that I made to get PHP working:
Code:
LoadModule php4_module        libexec/apache/libphp4.so
AddModule mod_php4.c
AddType application/x-httpd-php .php
PS 1
I'm running an older version of apache (1.x) and PHP 4
 
Old 01-21-2007, 11:46 PM   #5
mastahnke
Member
 
Registered: Feb 2002
Location: IL
Distribution: Ubuntu currently, also Fedora, RHEL, CentOS
Posts: 111

Original Poster
Rep: Reputation: 15
I don't think my point is coming across.

test.php is rendered as php (as I would like).


test.php.html is also rendered as php. This is incorrect. This should be rendered only by the browser and not pre-parsed by Apache.

If I use the configuration listed above, I get only php renderings on both accounts.

If I remove the php module, then the html renders fine, but of course test.php doesn't render at all.

MIKE
 
Old 01-22-2007, 01:29 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Your point WAS coming across, but maybe no longer:
  • test1.php works ok (parsed by apached; you see the phpinfo() screen)
  • test1.html works ok (not parsed by apache, you see the text of the page)
  • test1.php.html does not work (still parsed by apache; you see the phpinfo() screen)

Quote:
If I use the configuration listed above, I get only php renderings on both accounts.
Which one? The config that I posted or the one that you posted? Is that not what you wanted? What are accounts (in this context)?

Last edited by Wim Sturkenboom; 01-22-2007 at 01:30 AM.
 
Old 01-22-2007, 08:39 AM   #7
mastahnke
Member
 
Registered: Feb 2002
Location: IL
Distribution: Ubuntu currently, also Fedora, RHEL, CentOS
Posts: 111

Original Poster
Rep: Reputation: 15
/etc/httpd/conf.d/php.conf (without comments)
Code:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php
AddType application/x-httpd-php-source .phps

I still get the same issues.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2, PHP 5, SuSE 9.2 - cannot run php files dickohead Linux - Networking 6 06-28-2006 10:25 AM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
slackware, apache and PHP from .tgz - problems with PHP szymon Slackware 2 09-06-2004 04:57 PM
Set up Apache to read php IN html code? WorldBuilder Linux - Networking 10 01-27-2004 12:16 PM
reinstalled apache, php, still no php support SuSE 8.2 hindenbergbaby Linux - Software 1 10-14-2003 01:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration