Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

PHP showing blank page

What am I not doing that I should be doing?

- Apache server is running

before I did anything else I browsed to http://localhost/info.php and received an error stating that the page could not be found.

- Turned on PHP 5 module
- Restarted Web Services

No it just shows a completely white page. What do I still need to change? Something in the httpd.conf file?

Mac Pro G5, Mac OS X (10.6.6)

Posted on Jan 14, 2011 2:28 PM

Reply
9 replies

Jan 15, 2011 6:32 AM in response to parri2bd

Current Mac OS X client and Mac OS X Server both include fully functional Apache and php5 software.

The following presumes web services are configured, and not running, on Mac OS X Server:

With Mac OS X Server, copy over and customize the /etc/php.ini file from the provided default file, and customize as required (via nano, vim, emacs or another plain-text editor). This file needs to be readable by the www web server user.

Then ensure that the php5_module module is selected and loaded within Server Admin.

Then enable whichever site you're working with to have CGI Execution enabled with the particular site selected in Sites section of the Web set-up within Server Admin. (You may also need overrides or other settings here, but that's a different decision and different discussion.) I'm guessing that this is the step that you've missed here.

Start (or restart) web services.

Your php test file (<?php phpinfo(); ?>) should then be located in the default web directory for the particular site, as determined by the Sites set-up within Server Admin. By default, the default web server directory is the /Library/Webserver/Documents/ directory, though that can be customized.

Your web-facing files and directories should be readable by the _www user, but should generally not be owned by and not writeable by that user. This usually means the www is set as the group, or via ACL. This specific ownership and protection to try to limit the damage from a web server or php script breach. The web gremlins are perpetually trying php cross-site and SQL injections against php sites.

As for Mac OS X client, [Here is the php the set-up sequence for the client version of Mac OS X|http://labs.hoffmanlabs.com/node/1462], and some related set-up information.

Jan 15, 2011 8:52 AM in response to MrHoffman

@MrHoffman

So I am closer I guess.

I move the info.php file into a new folder called PHP. I setup a new site that is pointed to the PHP folder. I turned on CGI Execution. However, now when I browse to the info.php ("http://localhost/PHP/info.php") it downloads the page instead of rendering it in the browser. How do I get around that?

Jan 15, 2011 11:09 AM in response to parri2bd

I move the info.php file into a new folder called PHP.
I setup a new site that is pointed to the PHP folder.


Huh?

I turned on CGI Execution.


Good.

However, now when I browse to the info.php (" http://localhost/PHP/info.php ") it downloads the page instead of rendering it in the browser. How do I get around that?


Launch Terminal.app, and use the following general sequence as a starting point for your set-up:


$ cd /etc
$ sudo cp php.ini.default php.ini
$ # nano is a command shell text editor. directions for its use are displayed at the bottom.
$ sudo nano php.ini # whatever changes you need to this file
$ cd /Library/Webserver/Documents/
$ echo "<?php phpinfo(); ?>" > phptest.php
$ sudo chown root:www phptest.php
$ sudo chmod u=rwx,g=rx,o=rx phptest.php


Restart the web server.

The above is the general configuration sequence for the php.ini file, and it sets up a stub phptest.php file in the default web directory.

There is no need to create a php subdirectory, and no need to place php files anywhere other than the default web directory location.

If the above sequence fails, check the web server logs for any available details on the failure.

Jan 15, 2011 1:04 PM in response to parri2bd

At the risk of stating the obvious, your test file info.php should look like this (as stated by MrHoffman):

<?php phpinfo(); ?>

It should NOT look like this:

<? phpinfo(); ?>

This will NOT work in the standard configuration of PHP installed by 10.6 Server because short opentag is turned off by default - probably because it interferes with XML document declarations. This tripped me up in some old PHP files when I upgraded from OS X Server 10.5 to 10.6.

View the source of your test page using your web browser (Cmd-Option-U in Safari) to see what the browser is actually receiving. If there is NOTHING in the source view, this was not the problem and I apologize for wasting the bits and bandwidth.

Mar 22, 2011 10:42 AM in response to Bob Dreano

@ Bob: Thanks for the tip - this (<?php phpinfo(); ?>) helped me to proof, that php is actually up and running.

But I get blank pages with every other (i.e. wordpress) .php-file. Why? Are they all programmed "false"?

I changed the short opentag to "on" in the actual php.ini but this did not solve the problem.
Any idea?

Regards
T I L L

Message was edited by: Till...

PHP showing blank page

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.