Firefox no longer opens php page

Installed Apache and PHP, which worked out of the box for a week or so. Suddenly Firefox refuses to open an index.php but offers to download page only. How come?

When this is only “suddenly” without any change in configurations and/or software, how can we know? It is only you that can sit down and try to remember all the changes (specialy with respect to Apache and PHP) done to the system between the moment it worked and the moment “suddenly”.

BTW, Firefox is the user agent/HTTP client/browser and thus is not responsible for opening index.php. It asks (through the user’s wish) for that URL and then Apache, the HTTP server, tries to find it and “open” (or do something different with) it

But it seems that Apache has now no idea anymore that it should offer that PHP file to the PHP interpreter and then send the PHP output to the user agent/client/browser.
Instead it sends it as a file (with an yet not known MIME type) to the browser, which then, not knowing what to do with this MIME type, asks the user if he wants it downloaded.

Download it and see what is there; chances are that somehow the server is
sending the file with a MIME type other than text/html and so Firefox sees
it as something other than a webpage; for example, if the server side is
no longer parsing the PHP as PHP, then it may send the PHP file, which is
not HTML, resulting in what you see. The problem is almost certainly the
server, but we will not know until you test.


curl -v your.server.here/path/to/page.php


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Sorry for confusing post. Just to clarify the problem:

  • created a page at local host and uploaded to http://mistelberger.net/DokuWiki/doku.php?id=start

  • accessed the latter page and verified that both links on that page were working in Firefox on 23. November 2016

  • performed several Tumbleweed updates arriving through Software Updater

  • revisited that page on 29. November 2016 and found the first link working as expected, but the second link prompting: open with KWrite (Standard) …

I never told Firefox to open php with Kwrite.

On 11/29/2016 09:46 AM, karlmistelberger wrote:
>
> Sorry for confusing post. Just to clarify the problem:
>
> - created a page at local host and uploaded to
> http://mistelberger.net/DokuWiki/doku.php?id=start

Uploaded the page? I am guessing it is actually just a linking service,
since the link actually has ‘localhost’ in it, which is invalid for most
of the world (everybody but those on your computer).

> - accessed the latter page and verified that both links on that page
> were working in Firefox on 23. November 2016

In the latter case, the Firefox instance is accessing the local system,
but should still be doing so via HTTP, so still using Apache httpd for
that (presumably).

> - performed several Tumbleweed updates arriving through Software
> Updater

Which ones, and which ones in particular apply to Apache httpd (or Firefox
if you want, but it’s likely irrelevant)?

> - revisited that page on 29. November 2016 and found the first link
> working as expected, but the second link prompting: open with KWrite
> (Standard) …

See previous reply, and post the output from the test ‘curl’ command
mentioned there.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

I repeat that we both said that Firefox (or any other browser) is not the culprit.

When Apache offers, wrongly, the PHP text to the browser, the browser must take some action. As it is probably offered as text, Firefox thinks that Kwrite may be a good idea. But it should not have been send to Firefox in the first place. Apache should have let it executed by PHP and then sending the results to Firefox.

BTW, I can load the link you posted above (which is a PHP script to be executed on the server by Apache/PHP) and I receive a text/html page that is dully rendered by Firefox.

When I click the first )23. November) link, I do get the same page.

When I click the second link (21. November), that won’t work because it is to localhost anf my localhost is different from your’s.

But both links have no indication whatsoever about the contents of those URLs It ends simply on DokuWiki. It will depend om the Apacahe configuration. Apache mostly works with suffixes to identify the type of a file. But DokuWike had not suffix. Nevertheless, after sneding it, it Firefox addressbar is: doku.php. Thus some re-direct?

In any case, I get no download with or without the offer to sue Kwrite.

karl@erlangen:~> curl -v http://localhost/dokuwiki/index.php
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /dokuwiki/index.php HTTP/1.1
> Host: localhost
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Tue, 29 Nov 2016 17:16:12 GMT
< Server: Apache
< Last-Modified: Sun, 23 Aug 2015 13:57:26 GMT
< ETag: "b6-51dfae1825d80"
< Accept-Ranges: bytes
< Content-Length: 182
< Content-Type: application/x-php
< 
<?php
/**
 * Forwarder to doku.php
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <andi@splitbrain.org>
 */
header("Location: doku.php");
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
karl@erlangen:~> 

As assumed, Apachhe is not executing the PHP script, which in this case will create no ouput to be send to Firefox, but will redirect to doku.php. Instead it sends the found index.php with

Content-Type: application/x-php

to Firefox, which then tries something, but what FF tries is not very important, that is only a symptom.

We have to find out why Apache does not execute the PHP. And you say, it did earlier, without you (or any other) changing anything in the PHP script index.php, nor in Apache’s configuration?

I did write some PHP, but I am by no means an expert. Let me say, that it wonders me that you start the PHP part with

<?php

but you dp not close it off with

?>

It could be that this is not a requirement, or that it is, but that PHP is nice to you, but to me it looks like sloppy programming.

Thanks for pointing to real problem. That made me search further and I stumbled upon Apache not processing php file in Linux/OpenSuse - Stack Overflow which states “you have to run: a2enmod php5”. That fixed the problem!