XAMPP: PHP not working. Help!

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

XAMPP: PHP not working. Help!

Postby Abusername » 01. August 2009 09:47

Hi.
I have XAMPP installed for OS X and PHP is not working. If I run the following code, nothing happens:
Code: Select all
<?php phpinfo(); ?>

I just get a white screen.

I don't know what I'm doing wrong.
I launch XAMPP Control Panel.app and start all the components. I've also tried restarting all components. No luck.
My .html and .php files are in the right location (Macintosh HD/Applications/xampp/xamppfiles/htdocs).

What would be the next logical steps to troubleshoot this?
Thanks.
Abusername
 
Posts: 11
Joined: 21. February 2009 10:41

Re: XAMPP: PHP not working. Help!

Postby Wiedmann » 01. August 2009 11:08

Code: Select all
<?php phpinfo(); ?>

I just get a white screen.

What's the name of this file, how did you open it?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: XAMPP: PHP not working. Help!

Postby izym » 01. August 2009 15:20

Have a look at the outputted HTML code. Is your PHP code there? Since the PHP stuff is inside brackets, HTML will try to parse it if PHP for some reason does not. And of course make sure it really is a .php file (not likely, but you never know.)
izym
 
Posts: 2
Joined: 31. July 2009 12:38

Re: XAMPP: PHP not working. Help!

Postby caltuna » 01. August 2009 19:59

If you have a blank line above the first php "tag" you can have problems getting Apache to parse it with PHP.

Also, if you created the test file in TextEdit, you can sometimes get "junk" in there if you have RTF turned on.

Download the FREE TextWrangler program at http://www.barebones.com/products/TextWrangler/ and ALWAYS use that for creating PHP and HTML files.
caltuna
 
Posts: 111
Joined: 05. May 2009 16:35

Re: XAMPP: PHP not working. Help!

Postby Abusername » 05. August 2009 05:13

@izym: The browser window is totally blank (white) in Firefox. In Safari and Opera the code shows up in the browser window but is unparsed.

@caltuna: I know what you mean, but that is not the case for me. I disabled Rich Text Formatting in TextEdit long ago. It saves as .txt by default now and I simply retype the extension to .php
If I create the file in Dreamweaver I get the same result, so I'm thinking it has to be an Apache/PHP problem rather than a problem with my files.

Weird thing is I feel like I had PHP working on my local machine before. Unless my memory is wrong and I was uploading to my server each time I needed to test a script. I can't recall for certain.
Abusername
 
Posts: 11
Joined: 21. February 2009 10:41

Re: XAMPP: PHP not working. Help!

Postby caltuna » 05. August 2009 06:05

What does the apache log in XAMPP say? That might give you a clue.

I assume you don't get the orange XAMPP start page when you enter: http://localhost in the browser?

Have you made any changes to httpd.conf or php.ini files?

Maybe it is a permissions problem. How about stopping apache and going to terminal and entering:

chmod -R 777 /applications/xampp/htdocs

re-start apace and try it again?

Maybe you have a hidden .htaccess file that is screwing things up (You can see them in TextWranger by clicking "Open Hidden" in File menu)
caltuna
 
Posts: 111
Joined: 05. May 2009 16:35

Re: XAMPP: PHP not working. Help!

Postby Abusername » 05. August 2009 07:50

@caltuna

Correct, http://localhost results in this:
Index of /

* .DS_Store
* PHP_Test.html
* apache/
* oldindex/
* webalizer/
* xampp/


There is no orange XAMPP start page or graphics of any kind.

I did as you advised. Running that command in Terminal did not resolve the problem. However, using TinkerTool I was able to show all hidden and system files and did find a hidden .htaccess file. Its contents are:
Options -Indexes

The file's icon is that of a Dreamweaver document. I'm not sure if that means Dreamweaver created it or Dreamweaver is just associated with it.
I thought that removing this file and restarting Apache might fix things, but it has not.

A couple of other things I noticed are:
- The application icon for XAMPP Control Panel looks like it's greyed out. Maybe it's supposed to be that way, but I certainly wouldn't have designed it like that.
- When I stop or restart XAMPP an error is output that may or may not be related. It reads:
XAMPP: Stopping Apache with SSL...
/Applications/xampp/xamppfiles/bin/apachectl: line 70: ulimit: open files: cannot modify limit: Invalid argument


Thanks for your help thus far. Any more ideas?
Abusername
 
Posts: 11
Joined: 21. February 2009 10:41

Re: XAMPP: PHP not working. Help!

Postby MegaChriz » 05. August 2009 09:39

Abusername wrote:The file's icon is that of a Dreamweaver document. I'm not sure if that means Dreamweaver created it or Dreamweaver is just associated with it.
This means the .htaccess file is just associated with Dreamweaver.

What happens if you go to http://localhost/xampp/ in the browser?

I remember I once managed to get also this problem (that PHP-code didn't get parsed), I somewhere changed a line what was about which filetypes should get parsed. I can't remember which file it was, probably some of the config-files that belongs to Apache.
MegaChriz
 
Posts: 158
Joined: 16. February 2009 15:04
Location: Amersfoort, The Netherlands
XAMPP Version: 1.8.3-3
Operating System: Mac OS X

Re: XAMPP: PHP not working. Help!

Postby MegaChriz » 05. August 2009 09:48

MegaChriz wrote:I remember I once managed to get also this problem (that PHP-code didn't get parsed), I somewhere changed a line what was about which filetypes should get parsed. I can't remember which file it was, probably some of the config-files that belongs to Apache.

Look for:
Code: Select all
AddType application/x-httpd-php .php .php3 .php4 .php5

in httpd.conf or httpd-xampp.conf
and check if this is accidently commented out.
MegaChriz
 
Posts: 158
Joined: 16. February 2009 15:04
Location: Amersfoort, The Netherlands
XAMPP Version: 1.8.3-3
Operating System: Mac OS X

Re: XAMPP: PHP not working. Help!

Postby Abusername » 05. August 2009 10:01

MegaChriz wrote:What happens if you go to http://localhost/xampp/ in the browser?

http://localhost/xampp/ shows the orange XAMPP page! That's a good sign, I think.

I found the line in httpd.conf that you mentioned, but it wasn't commented out.
Abusername
 
Posts: 11
Joined: 21. February 2009 10:41

Re: XAMPP: PHP not working. Help!

Postby MegaChriz » 05. August 2009 14:20

If the XAMPP-page shows up, PHP should be working alright.

Maybe you tried to open your php-page one of these ways:
- you double clicked on the file while you were in the Finder;
- from the Finder, you dragged the file to the browser application.
The two above methods are not the right methods to view a PHP-page. You need to access the file via localhost (or a ip-address). For example http://localhost/test.php

To let the file be parsed as php, you need to let the name of the file end on .php, not on .html.

If above did not help you, I have two questions:
1. What is the name of the file?
2. What is the url in the browser when you accessed the file?
MegaChriz
 
Posts: 158
Joined: 16. February 2009 15:04
Location: Amersfoort, The Netherlands
XAMPP Version: 1.8.3-3
Operating System: Mac OS X

Re: XAMPP: PHP not working. Help!

Postby Wiedmann » 05. August 2009 20:50

Correct, http://localhost results in this:
Index of /

* .DS_Store
* PHP_Test.html
* apache/
* oldindex/
* webalizer/
* xampp/

There is no "index.php" in this collection. Have you deleted some files in "htdocs" (or better: you must have)?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: XAMPP: PHP not working. Help!

Postby Abusername » 06. August 2009 09:28

@MegaChriz: It worked!!! Not at first, but it worked. Thank you!!! :mrgreen:
I'll explain...

The first problem was that I was opening the files from Finder, choosing "Open With..." or dragging to the browser icon, like you said.
Maybe in the beginning I knew the proper way to view the files, but after setting PHP down for a few months I forgot. That would explain my memory of having a working test server at one point. :)

Second problem: In anticipation of working on multiple PHP-driven websites, I created a subfolder "WebsiteName" within the htdocs folder.
I figured I could add more sites accordingly with time and it would be a good way to stay organized. I guess instead it broke my PHP functionality.

After reading your last suggestion I tried http://localhost/WebsiteName/test.php to no avail. Got a "500 Internal Server Error". But then I tried moving the test.php file up one folder so that my filepath matched your example verbatim and now it works! http://localhost/test.php works!

So with that problem solved, now I ask: why does putting the PHP files in a subfolder stop them from being parsed?
And what is the correct way to manage multiple sites, if not with subfolders?

Thank you!
Abusername
 
Posts: 11
Joined: 21. February 2009 10:41

Re: XAMPP: PHP not working. Help!

Postby MegaChriz » 07. August 2009 09:26

You should be able to work with subfolders. Why you get a '500 Internal Server Error' can be because there is a .htaccess-file that is screwing things up.
Is there a .htaccess file in the folder 'WebsiteName'?

Be careful with editing .htaccess-files in Mac OS X. The line-breaking character that is used default in Mac OS X can cause a damaged .htaccess-file which will result in a '500 Internal Server Error'. If you edit a .htaccess-file you need to set the line-breaking character to Unix in the editor you are working in. I've read you were using Dreamweaver.
1. In Dreamweaver, choose preferences from the Dreamweaver menu.
2. Go to 'Code Format'.
3. Set 'Line breaking type' to 'LF (Unix)'.

If there is no .htaccess file in the folder 'WebsiteName', try to create another folder inside the folder htdocs and try if you will also get a server error there.
MegaChriz
 
Posts: 158
Joined: 16. February 2009 15:04
Location: Amersfoort, The Netherlands
XAMPP Version: 1.8.3-3
Operating System: Mac OS X

Re: XAMPP: PHP not working. Help!

Postby tabman711 » 04. February 2011 09:01

Thank you that fixed my problem as well.
Steve
tabman711
 
Posts: 3
Joined: 04. February 2011 08:08


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 4 guests