1

Im using a linux machine, and I followed the instructions seen on https://www.php.net/manual/en/install.php to setup php, apache and my sql.

I did exactly what it said and nothing more, but when I try to open a .php file with firefox or chrome, it downloads...?

Im following a tutorial on learning php seen here: http://devzone.zend.com/node/view/id/625

2
  • What url are you trying to use in Firefox/Chrome? Just want to make sure you aren't trying to serve the file through Firefox rather than through Apache. Commented Apr 9, 2010 at 2:27
  • /home/USERNAME/WORK/PHP/Test_Page.php Commented Apr 9, 2010 at 2:38

2 Answers 2

1

Note that if you have a file:// URL in the browser address bar it isn't interacting with the server to process the page.

You will need to use http://localhost/path/to/page/page.php

Sign up to request clarification or add additional context in comments.

11 Comments

So all im doing is replacing the 'file' with 'http'? Thanks for the response
file:// forces you browser to act as a very dumb version of the regular file manager on your OS. It will not cause the script to be run by the webserver, as the webserver never gets involved. Switching to http:// will send a request to the webserver, which will load the script on your behalf.
Means that the server is running but you need to put your PHP scripts in that directory.
Define "nothing happened" better please. You saved the php file to /var/www and then loaded http://localhost/[filename].php into your web browser and nothing happened? No errors? Nothing?
Yeah, rename the file index.php and you can just type in http://localhost/. Also, you don't have to retype it everytime, just refresh the page.
|
1

According to this howto:

https://www.php.net/manual/en/install.unix.apache.php

Please make sure you did steps 14 and 15, what is happening - probably your webserver doesn't recognize php scripts AS php scripts, and sends those to your browser - resulting in either download or displaying the source.

Thanks

3 Comments

I have Apache 2.x on my machine. But I will attempt your suggestion, thanks for response
I ran the code 'LoadModule php5_module libexec/libphp5.so' in the terminal, it says 'command not found'. So I didnt bother to go to number 15
LoadModule is not a command, you need to put it into apache's config. For v2.0: Steps 7 and8 from this howto: jm2.php.net/manual/en/install.unix.apache2.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.