Forum Moderators: phranque
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!
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
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?
[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
----------------------------------------------------------
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
here is my HTTP Live Headers output
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
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.