Forum Moderators: phranque

Message Too Old, No Replies

<IfModule mod php5.c> fails randomly?

         

jburns131

7:17 am on Dec 9, 2008 (gmt 0)

10+ Year Member



First of all, here are some system specs:
Ubuntu 8.10
Apache 2.2.9
mysql Ver 14.12 Distrib 5.0.67
PHP 5.2.6

I believe that the <IfModule mod_php5.c> statement in my php5.conf file fails randomly.

For some reason, when browsing my site, I get the "Open/Save File" dialog box when clicking on links to .php files.

I have installed lamp using the Debian/Ubuntu tasksel package manager (sudo tasksel lamp).

Here are are the directives regarding php that I have in my file system (Ubuntu splits the httpd.conf file into multiple files):

php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

php5.conf
<IfModule mod_php5.c>
AddHandler php5-script php
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html index.htm
</IfModule>

mime.types
application/x-httpd-phpphtml pht php
application/x-httpd-php-sourcephps
application/x-httpd-php3php3
application/x-httpd-php3-preprocessedphp3p
application/x-httpd-php4php4

I think that's it, my brain is a bit fuzzy at the moment.

Anyways, I think the <IfModule mod_php5.c> is failing randomly because apache only asks me to download the .php files randomly.

A lot of the times apache will parse a .php page correctly, then asks me to download the file when I refresh. It also asks me to download .php files the first time I visit a .php page. I can either continue clicking on the link to the .php file in a nav menu till it parses correctly, or sometimes clear my browser cache and refresh the page (F5) and it will parse correctly.

I have spent the past 48 hours researching this issue and I think I have narrowed it down to the <IfModule mod_php5.c> statement.

The main thing I learned about the <IfModule mod_php5.c> statement is that apache is checking to see if the "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so" statement loaded libphp5.so correctly.

Can anyone explain to me how the <IfModule mod_php5.c> statement can fail randomly? Or how the "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so" can fail randomly? Aren't these statements run only once during server start/restart/force-reload?

If I'm missing something, or you need more info from me, please let me know. Thanks!

g1smd

10:55 am on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use HTTP Live Headers to see what TYPE the content is being sent as.

It should be

text/html
. It is likely that it is being sent as something else.

jdMorgan

3:24 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless this code is to installed on multiple servers with varying module support, there is no need for any of the <IfModule> containers.

The typical purpose of <IfModule> containers is to allow requests to fail silently if module support is not present on a server, and that is arguably something which many Webmasters wouldn't like. If I don't have a module installed, I'd rather get a big pile of errors, so that I would know I had a problem...

However, <IfModule> is not at all likely to fail intermittently, so this is probably a Content-Type problem as g1smd suggests. If you are debugging with IE, be aware that it usually ignores the HTTP Content-Type header returned by the server, and tries to 'infer' the correct content-type based on the actual content returned by the server. *That* behavior is much more likely to be flakey.

You might actually find that you *always* see this download problem with Mozilla, Opera, and Safari browsers, because they correctly use the Content-Type header in accordance with Web standards. Recommended practice: Develop and debug code and CSS with Firefox or Safari, then do a final compatibility check with IE6 and IE7.

Jim

jburns131

11:42 pm on Dec 15, 2008 (gmt 0)

10+ Year Member



Sorry to take so long to respond.

g1smd, it says the Content-Type is text/html. This is the output I got from HTTP Live Headers:

Date: Mon, 15 Dec 2008 23:24:59 GMT
Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch
Last-Modified: Mon, 15 Dec 2008 20:13:43 GMT
Etag: "12a6d6-2cf-45e1b7aba4bc0"-gzip
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 348
Content-Type: text/html

200 OK

Could it be the Content-Encoding?

jburns131

12:04 am on Dec 16, 2008 (gmt 0)

10+ Year Member



Sorry, that was my "Web Developer" output. This is all on my local test box, so here is my HTTP Live Headers output:

[localhost...]

GET /pear/PhpDocumentor/ HTTP/1.1

Host: localhost

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Cookie: e107cookie=1.193b790ee883695526cac4c1b495ff24; e107_tzOffset=300; e107_tdSetTime=1229383499; e107_tdOffset=2

If-Modified-Since: Mon, 15 Dec 2008 20:13:43 GMT

If-None-Match: "12a6d6-2cf-45e1b7aba4bc0"-gzip

Cache-Control: max-age=0

HTTP/1.x 200 OK

Date: Tue, 16 Dec 2008 00:00:36 GMT

Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch

Last-Modified: Mon, 15 Dec 2008 20:13:43 GMT

Etag: "12a6d6-2cf-45e1b7aba4bc0"-gzip

Accept-Ranges: bytes

Vary: Accept-Encoding

Content-Encoding: gzip

Content-Length: 348

Keep-Alive: timeout=15, max=100

Connection: Keep-Alive

Content-Type: text/html

----------------------------------------------------------

[localhost...]

GET /pear/PhpDocumentor/docbuilder/blank.html HTTP/1.1

Host: localhost

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Cookie: e107cookie=1.193b790ee883695526cac4c1b495ff24; e107_tzOffset=300; e107_tdSetTime=1229383499; e107_tdOffset=2

If-Modified-Since: Mon, 15 Dec 2008 20:13:43 GMT

If-None-Match: "12a340-1cf-45e1b7aba4bc0"-gzip

Cache-Control: max-age=0

HTTP/1.x 200 OK

Date: Tue, 16 Dec 2008 00:00:36 GMT

Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch

Last-Modified: Mon, 15 Dec 2008 20:13:43 GMT

Etag: "12a340-1cf-45e1b7aba4bc0"-gzip

Accept-Ranges: bytes

Vary: Accept-Encoding

Content-Encoding: gzip

Content-Length: 319

Keep-Alive: timeout=15, max=99

Connection: Keep-Alive

Content-Type: text/html

----------------------------------------------------------

Caterham

4:00 pm on Dec 16, 2008 (gmt 0)

10+ Year Member



php5.conf
<IfModule mod_php5.c>
AddHandler php5-script php
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html index.htm
</IfModule>

mime.types
application/x-httpd-phpphtml pht php
application/x-httpd-php-source phps
application/x-httpd-php3 php3
application/x-httpd-php3-preprocessed php3p
application/x-httpd-php4 php4

You don't want to set MIME-types via mime.types or AddType to parse php files [mail-archives.apache.org]. Use AddHandler.

<IfModule mod_php5.c> is failing randomly

It can't. The configuration file isn't read per each request but at server startup as you noted. Either the module is there, or not. If the content wouldn't be parsed, you should download php source code, but if you're prompted for download, I guess you get parsed output, may be gzpi'd output?

here is my HTTP Live Headers output

And this time you were asked to download the file?

jburns131

3:14 am on Dec 17, 2008 (gmt 0)

10+ Year Member



yes, I waited till it happened again and that was the output.

jdMorgan

7:02 pm on Dec 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which browser were you using when you were asked to download this file? As above, IE ignores the Content-Type/MIME-type sent in the server's HTTP response headers, while other browsers use it as intended.

I'm wondering if perhaps the Apache module execution order is going wrong here, and Apache is gzipping the PHP before trying to execute it. This would be a possible tie-in with using AddType instead of the proper AddHandler...

Jim

jburns131

12:06 am on Dec 19, 2008 (gmt 0)

10+ Year Member



Sorry, I'm using Firefox 3.0.5 (working on a ubuntu box).

I'm going to do two things:

1 - Change the "AddType" to "AddHandler"

2 - Install another browser to see if it might be Firefox

jburns131

8:12 pm on Dec 23, 2008 (gmt 0)

10+ Year Member



This continues to happen, no matter which browser I use.

I've changed all "AddType" entries to "AddHandler".

This is completely random. This is my work flow:

I'll edit a php file, then go to refresh the page. Some times it works, at other times it asks me to download to file.

Sometimes, when loading phpmyadmin, it will load the right hand side page (located in a frame), yet it will ask me to download the "nav.php" (the left hand side). So in one request from the server, it's pulling one php file, yet asking me to download the other php file that it's loading.

Any idea's? I've reinstalled multiple times, yet this continues to happen.

jburns131

8:28 pm on Dec 23, 2008 (gmt 0)

10+ Year Member



Here's my error log for the past few hours: [paste2.org...]