[ltp] [OT] Help re: php / Apache

Richard Neill linux-thinkpad@linux-thinkpad.org
Mon, 07 Apr 2008 18:33:10 +0100


Dear Jeffrey,

> 
> Suddenly, I lost all php function.  When I hit a .php page, it asks me
> if I want to download it.  

That sounds to me as though your browser is interpreting the MIME type
wrongly. If you do download the contents, and open in an editor, do you
get what you expect to see? (i.e. a raw HTML page, with the contents
dynamically generated by PHP?)

If so, then your browser is being told the wrong content type from your
webserver, and doesn't recognise it; the browser then offers to save the
file, but won't display it.

Here is a a useful diagnostic:

(1)Telnet to the  webserver on port 80.

  telnet localhost 80


(2)You will hopefully get this response.

  Trying 127.0.0.1...
  Escape character is '^]'.


(3)Manually make the request from the server:

  GET /path/to/page.php HTTP/1.0

(4)You'll get the page contents directly printed to screen, and telnet
will exit.

(5)This output begins with some HTTP headers, such as:

  HTTP/1.1 200 OK
  Date: Mon, 07 Apr 2008 17:22:14 GMT
  Server: Apache/2.0.54 (Mandriva Linux/PREFORK-13.3.20060mdk)
  X-Powered-By: PHP/5.0.4
  Content-Type: text/html; charset=iso-8859-1

(6)In the HTTP headers (not to be confused with <head>...</head>),
you'll see a content-type. This is what tells the browser what to do
with the information.  .php pages should usually be associated with
text/html.

Other common types are
  .txt  -    Content-Type: text/plain
  .pdf  -    Content-Type: application/pdf

And unknown types usually appear as   Content-Type:
application/octet-stream.


(7)You browser only knows how to deal with a limited set of types, and
it's a fair bet that apache is configured to send the wrong mime type
for PHP.

Is this your problem? If so, check php.ini, and ensure you have
  default_mimetype = "text/html"

I have tried EVERYTHING.  Including returning
> all network settings to previous, reinstalling apache2, reinstalling
> php, and going back to yast to ensure php is enabled.  The
> etc/sysconfig/apache2 clearly shows php in its list of modules.  Apache
> works otherwise.  PHP is clearly installed, I can run scripts from the
> command line.  Tried different browsers:  same problem.

Did you do a full purge/uninstall? Usually, when you remove packages,
the configuration files are helpfully left behind, so that you don't
lose your settings! So your uninstall/reinstall probably didn't discard
the file with your changes in it (which in this case, was the one you
really wanted to get rid of!).

Hope that helps.

Best wishes,

Richard