2

I'm working through a PHP tutorial and I'm having issues because I can't open local php files in firefox. I just get prompted to open them with another program. I'm using a mac, btw. Things I've tried/already know:

  • Deleting the mimetype.rdf file
  • Control+clicking the file and choosing to open with firefox. won't work because firefox is always grayed out.
  • I do have a local webserver installed. I've been having troubles with the native Mac local webserver, so I installed MAMP and I can serve up javascript files just fine.
  • I came across something about removing php from your download actions, but I can't seem to find anything about what that actually means or how to do it.

I've been looking all over the internet for a solution to this, it seems really crazy to me that I can't find anything. I know there are some similar questions posted on here, but they all seem to have particular aspects that don't apply to my case. I also found something about this on the MAMP forums but it was never resolved from back in 2008. Anyone?

kacmcgrath
  • 137
  • 2
  • 12
  • it promts download because your server does not support php correctly, normally you will see the php output – Marco Mura Dec 19 '14 at 12:01
  • Maybe this is a dumb question, but since you're not experienced you might be missing the basics. Are you actually accessing you PHP files through your local webserver? Or are you just double-clicking them in your finder? – kos Dec 19 '14 at 13:49
  • The files are in my MAMP root directory. I have tried to access them every which way including typing the path in the browser, right clicking and choosing "open with", double clicking, etc. Not a dumb question, though. I probably wouldn't have known to do that if it weren't covered in the tutorial. – kacmcgrath Dec 19 '14 at 17:28

6 Answers6

2

This can mean that you don't have PHP installed, or PHP is not configured correctly. You need to ensure the file is in the directory where your webserver is installed and you need to request the script via your localhost/path/to/file/ you cant just open a PHP file in firefox you will need to request if via your webserver.

  • 2
    I think he does have PHP installed and it's likely configured correctly, he's just not accessing it via localhost, like you say. Also, note that you need to put your php file in your server root, typically somewhere like [mamp_root_folder]/htdocs/ – Matthew Haworth Dec 19 '14 at 12:22
  • It's probably true that the MAMP version of PHP is not configured correctly. I will look in to that. Thanks. – kacmcgrath Dec 19 '14 at 17:29
1

Well the solution is rather simple actually:

  1. Make sure your local host software like MAMP is installed and running. Your php will NOT run without it.
  2. Place your .php file in the applications/mamp/htdocs folder.
  3. Open a new tab in your browser.
  4. In the address bar type the following localhost/filename.php
  5. Hit enter.
  6. You are done.

If you are not suffering from any conflicting software your php should run and you will see the desired page.

Right clicking and directing the file to open with Firefox will not help. I'm sure there is a better and proper solution. But if you are in a rush for a quick fix - this is it!

Dmitriy
  • 11
  • 1
0

Firefox has had an intermittent bug for years in which it would prompt for download files which should be shown in the browser. Many times this could be attributed to incorrect MIME type configuration, or to a misconfiguration in the webserver's presented Content-Type or file handlers. However, I have personally diagnosed with Wireshark conditions under which the webserver would present the proper Content-Type and the browser was properly configured.

Therefore, you should:

  • Check that the server is properly parsing PHP files.
  • Check that the server presents the proper Content-Type
  • Check that the browser is configured to properly handle the Content-Type presented by the server.
Community
  • 1
  • 1
dotancohen
  • 30,064
  • 36
  • 138
  • 197
0

PHP files are just code. If you try to make a browser open it, all it knows to do is download the text file. You need to make sure that your code is being interpreted by PHP via your HTTP server.

egersh
  • 1
0

I worked through these instructions to solve a problem I was having with setting up my local Sites directory after upgrading Yosemite and then I could actually open the PHP file. Then I had to go to my httpd.conf file in /etc/apache2 and uncomment LoadModule php5_module libexec/apache2/libphp5.so to get the PHP to actually load.

For a summary of what is included in the instructions for setting up apache after upgrading to Yosemite, see my answer in this post .

Community
  • 1
  • 1
kacmcgrath
  • 137
  • 2
  • 12
-1

Click Here

All who are having this problem should check this link. After doing this it seems the problem is not MAMP but with firefox because my websites worked with Safari on port:80 after following these simple instructions but still not with Firefox. I hope I helped and goodluck.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Mekanic
  • 137
  • 2
  • 10