Browser Downloads .php Files Instead of Displaying

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Browser Downloads .php Files Instead of Displaying

Postby miss9 » 29. April 2016 18:22

I'm running Linux Mint 17.20 32-bit as a guest on VirtualBox. Host machine is Windows 10. After downloading Xampp for Linux and starting up the Apache server, I am still unable to make .php files run. I tried testing that PHP was correctly installed by opening the htdocs/index.php in my browser, but my browser (latest FireFox & Opera) tries to download the document instead. I've also tried creating a test.php file in my system's var/www directory, and then directing my browser to that directory, but it says the file does not exist. I've tried installing Xampp/PHP two different ways now: downloading straight from Apache Friends site and installing apache & php packages via command line. What could possibly be wrong? How do I get .php files to render on my browser?
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby Altrea » 30. April 2016 05:28

How exactly did you try to "open" the file in your browser?
Which URL did you use to test the dashboard and your own file?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Browser Downloads .php Files Instead of Displaying

Postby miss9 » 30. April 2016 05:32

http://localhost/test.php typed in the browser. I also tried changing the file permissions as well.
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby Nobbie » 30. April 2016 10:48

What happens when you simply enter http://localhost in your browser? You may also simply click on that link.

Also, your description contains a certain contradiction, on the hand you say, that you opened "htdocs/index.php" in your browser, on the other hand, you say that you entered http://localhost/index.php in your browser. Which of these two is correct?

Also confusing is this one:

miss9 wrote:and then directing my browser to that directory


What do you mean by "directing" your browser to that directory?? There is no way to open files in /var/www with Xampp Apache configuration.

Finally, in which environment did you install Xampp (in Windows10 or in Linux Mint?) and in which environment did you run the browser?
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Browser Downloads .php Files Instead of Displaying

Postby miss9 » 30. April 2016 14:26

http://localhost takes me to a welcome to Xampp-Apache Friends page.

Sorry, yes, initially I was opening the htdocs/index.php file through the directory, selecting Firefox to open it with, which caused the download. But I later realized that was wrong (after my OP). Anyway, when I directly type in localhost/index.php the page is not found (though Apache IS up & running with no errors and index.php IS located in htdocs directory).

In my last comment I'm actually referring to the test.php file which I created after my second attempt at installing Apache/PHP (which I mentioned in my OP, but I see now I probably wasn't very clear). I put the test.php file (which just calls for the php version) in the var/www directory. After realizing I couldn't open the php file by double clicking it, I tried directing my browser to its location, localhost/test.php which also didn't work. It couldn't find the file, even though the file is there and again, Apache is up & running with no errors.

Finally, Xampp is installed in Linux Mint and the browsers were run in the Linux Mint environment. Thanks!
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby Nobbie » 01. May 2016 14:55

miss9 wrote:http://localhost takes me to a welcome to Xampp-Apache Friends page.


That means, PHP and everyting else is running perfectly.


miss9 wrote:Anyway, when I directly type in localhost/index.php the page is not found (though Apache IS up & running with no errors and index.php IS located in htdocs directory).


No, and no, and no! This simply CANNOT be true. Because the Xampp Welcome Page (it is called "dashboard") works only and only if index.php is working, because the index,php installed by Xampp redirects to the dashboard ("Welcome Page") and NOTHING ELSE!

I dont know, what you are doing actually, and i also dont know, what you are doing wrong. But i definately DO NOT believe in your error description, as you would not see any Welcome Page if loading of localhost/index.php fails!
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Browser Downloads .php Files Instead of Displaying

Postby miss9 » 01. May 2016 18:12

I know! It's why it's been driving me crazy because I kmoq it should work. Later when I'm infront of my computer I'll see if I can get some screenshots. Thank you for your help so far.
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby miss9 » 02. May 2016 18:02

I figured it out. As I went to go get some screenshots today, I realized I had placed test.php in the wrong folder. The tutorials I had followed had me place it in var/www instead of var/www/html. When I put it in var/www/html is works just fine. I think it's really weird that the tutorials didn't specify this...maybe they were outdated, or maybe I'm still doing something wrong. Maybe there's a way to designate var/www as the default location for localhost? I don't know, but at least it's working. Thanks for your help anyway @Nobbie.
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby Nobbie » 02. May 2016 18:37

miss9 wrote:When I put it in var/www/html is works just fine. I think it's really weird that the tutorials didn't specify this


"Weird" is, that you definately do NOT work with Xampp. I dont know if you even installed it, but you definately do NOT use it. Xampp is installed into /opt, the files are installed into /opt/lampp/htdocs. You are working with a standard Linux installation, you never started Xampp, you never saw a "Xampp" Welcome screen (i do not believe into your description, in fact you never ever have seen a "Xampp" welcome page). You never ever started Xampps Apache.

Forget about Xampp, forget everything you are thinking about Xampp: you dont use it!!
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Browser Downloads .php Files Instead of Displaying

Postby miss9 » 02. May 2016 18:46

I did. In fact, I uninstalled/reinstalled it a few times before I even thought to look for a tuturial on the standard Apache/PHP installation. I even ran into the issue of having to change the port the Xampp Apache was using, via Xampp, so that it wouldn't interfere with my standard installation. I just reinstalled Xampp (after uninstalling it for the 100th time) and ran it again. Localhost got me the Xampp page. But still couldn't "find" the test.php file (which I had made a copy of and put in htdocs directory). I cleared my browser's cache and now it works. At least it all works now, but I still don't know exactly what I was doing wrong before.
miss9
 
Posts: 6
Joined: 29. April 2016 18:11
XAMPP version: 5.6.20
Operating System: Linux Mint 17.3

Re: Browser Downloads .php Files Instead of Displaying

Postby Nobbie » 02. May 2016 21:08

miss9 wrote:At least it all works now, but I still don't know exactly what I was doing wrong before.


And i still dont know what you are doing and at least i dont know, which Apache you are running. I give up.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 96 guests