Nightmare trying to get PHP up and running.

A couple of years ago I spent 14 hours in a single day trying to get the PHP server up and running on my PC.

I've had an iMac since February and I've spent 12 hours so far trying to get PHP up and running under OS X 10.5.6.

I have edited the file /etc/apache2/httpd.conf so that the php line has the # removed, and so should enable PHP. I've rebooted my computer. However, if I create a file with the following:

<!DOCTYPE html PUBLIC "~//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml11/DTD/
xhtml1-transitional.dtd">
<html xmlns="http://www/w3.org/1999/
xhtml" xml:lang="en" land="en>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso=8859-1" />
<title?Basic PHP Page</title>
</head>
<body>

This is standard HTML.



<?php
echo 'This is a simple test.'
?>

</body?
</html>

and save it as test.php and the open it is safari, instead of seeing the test "This is a simple test." I see the whole of the text, as written above.

HELP! WHAT ON EARTH IS THE ONE OTHER SIMPLE THING THAT I HAVE TO DO. I AM *SO* WOUND UP OVER SPENDING 12 HOURS WITH THIS.

PLEASE! *PLEASE!* HELP ME WITH THIS.

iMac 24 inch, 2.8 GHz, Mac OS X (10.5.6)

Posted on Dec 28, 2008 7:54 PM

Reply
11 replies

Dec 28, 2008 11:09 PM in response to pforkes

I've copied your source code and tried it out on my server. It works.

It seems as though Apache is no longer parsing HTML either on your machine but is allowing a browser to read that file. I'm guessing that you are looking at this file on the same computer that the file resides on. If so, your browser has access to most any files, so we can't tell if Apache is really running. Look in your logs for error messages. I have a feeling you deleted something or put a Return character in the httpd.conf file where it doesn't belong.

Dec 29, 2008 8:10 AM in response to pforkes

Having spent over 12 hours yesterday trying to enable this (I even called AppleCare asking what I could use to edit /etc/apache2/httpd.conf and was told that they could not answer that question ⚠ so I installed Marc Liyange's PHP Apache module ( http://www.entropy.ch/software/macosx/php/) and now I cannot figure out how to uninstall it, because I cannot find it! I am guessing that this is now 'interfering' and that it need to be uninstalled.

When an application like this PHP APache module is not in the Application folder, how do you uninstall it?

If ONLY AppleCare had told me the name of an application that could edit /etc/Apache2/httpd.conf, yesterday, I wouldn't be in the mess I believe I am in now.

Dec 29, 2008 11:13 AM in response to pforkes

pforkes,

Did you edit the httpd.conf file using a regular word processor? If so, your httpd.conf file might be broken.

You need to use a text editor that doesn't leave behind any invisible data (like formatting data and carriage returns). You can use demo versions of BBedit or TextWrangler for just this one line. If you're comfortable with the Terminal, you could use pico.

As for the corrupt httpd.conf file... you can copy /etc/apache2/original/httpd.conf to /etc/apache2/httpd.conf and try again.

PHP is not an OS X application. It will not be installed as an executable in the Applications folder. Marc's PHP package installs PHP in a different directory than Apple's so that it doesn't overwrite the default PHP install. To remove, Marc gives you the following instructions on his site:

All software is installed into a new directory /usr/local/php5 on your boot volume. If you ever want to get rid of the package, you only have to remove this directory, symbolic links called +entropy-php.conf in either /etc/httpd/sites or /etc/httpd/users and, for older packages, a few easily recognized lines in the /etc/httpd/httpd.conf Apache web server configuration file.



To find out if Apache itself is running, try this command.

ps -ax|grep httpd



You should have one parent HTTPD and a few child HTTPD processes running. If you only have one process running, Apache maybe throttling (trying to start up but can't). This is probably because of an error in the httpd.conf file that you've edited.

Dec 29, 2008 11:26 AM in response to RedRhubarb

Hi Celia and pforkes,

Did you edit the httpd.conf file using a regular word processor? If so, your httpd.conf file might be broken.


I think you're on the right lines there Celia, but I think pforkes has saved their php test files as non-plain text file instead.

pforkes, please check that the editor you are using for the test.php file is instead saving as a plain text file. If you're using TextEdit, I think under the Format menu you can select 'Make Plain Text' (sorry, I'm not on a Mac right now so that might be not 100% correct).

Dec 29, 2008 12:19 PM in response to pforkes

I figured out I needed a better text editor that TextEdit so I downloaded TextWrangler to edit httpd.conf. However, even after the edit (and reboot) php still wasn't working properly, so I installed Marc's PHP.

If I shell out to a terminal and go to /usr/local and rmdir -p php5 I get a 'denied' error.

When I 'su' and type in the root password (which is (I presume the same as the one I type when I install a product) I get 'sorry'.

httpd is running as a process (I ran the program to automatic load it at start up, and I can't kill that either! (presumably because I need to be root).

This is turning into something reminiscent of a virus! As soon I a try and shut off one option another appears.

HOW DO I DELETE THE php5 FOLDER???
I've been using rmdir -p php5, with no luck, so do I need to be logged on as root? If so, then is my presupposition that the root password is the same one I enter before I install a program?

Dec 29, 2008 7:38 PM in response to pforkes

Since you are on a regular Mac OS machine, you should be able to stop Apache by stopping Web sharing from the *System Preferences* under the Sharing pane. If that does not work, you could try from the Terminal:

sudo apachectl stop


When you use sudo, you need the password for the current admin account, not root.

To remove a directory with contents still in it, you need to use the rm command with the -r switch:

sudo rm -r /usr/local/php5



Good luck.

Dec 30, 2008 5:38 AM in response to pforkes

It's a bit late in the day now but, from your original post I think you had everything correct.

and save it as test.php and the open it is safari, instead of seeing the test "This is a simple test." I see the whole of the text, as written above.


That usually just means the test.php document you saved, wasn't saved in plain text (I've done that a few times when working with PHP 🙂 )

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Nightmare trying to get PHP up and running.

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