Need to restart Apache for PHP to work?

I just bought a new MacMini, and can't remember exactly how I did this on my old MacBook.

I started WebSharing on the new computer (in the sharing control panel), and the webserver itself works fine.

I also opened the httpd.conf file and uncommented the LoadModule line for PHP, so that I could run my php files on the localhost (to test them before uploading them to a live server).

But I still can't get PHP working. I think I simply have to restart the apache server to get the change in the httpd.conf file to take effect, but for the life of me, I can't remember how to do that. (It's been a long while since I had to actually get down into the basics). I tried simply stopping and restarting the web sharing in the sharing control panel, but that didn't do it.

I KNOW there's a very simple step I missed, but as I said, I just can't remember what it is.

MacMini, Mac OS X (10.6.3)

Posted on Sep 28, 2010 9:08 AM

Reply
15 replies

Sep 28, 2010 12:30 PM in response to Daniel Lins

Daniel Lins wrote:
I tried several php scripts that work on my "live" server as well as on my MacBook. But when I navigate to them on the MacMini, they don't load correctly. They display the actual PHP code instead.


I'll take that as a "no" on the info.php 🙂

The first step is definitely the 3-line info.php in your home directory's Sites folder. If that works, PHP is functional and the problem is elsewhere - a vhosts config file, perhaps. If it doesn't work, then go back to the Apache config file and review the differences between that and a functional version.

Sep 28, 2010 12:44 PM in response to etresoft

Nope that WASN'T a "no" on the info.php. I DID try info.php. It was one of the "several" I mentioned. None of them work on my MacMini, so PHP is definitely not functioning. HTML works just fine, so the webserver itself is running.

The problem with comparing the config file to a functioning version is that my functioning version is on a MacBook running OS 10.5, while the MacMini is running OS 10.6. From what I've seen, there are several differences in the httpd.conf file between the systems (not just relating to php) so each difference in the file COULD be part of the PHP problem, or it could be simply a difference in systems.

Sep 28, 2010 12:55 PM in response to Daniel Lins

So all you did in your config file was uncomment the PHP line?

Have you tried the file from your Sites folder and from DocumentRoot? Create a new account and try it there. Sometimes there is "baggage" left over from old OS versions.

What do you get when you try to run php from the command?

PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


Finally, I hate to ask this, but I must. Any time someone complains about basic things not working, it is just due diligence. Have you installed any 3rd party software with the words "port" or "fink" in the name?

Sep 28, 2010 1:14 PM in response to etresoft

In the config file, yes. All I did was uncomment the PHP line. Nothing else. I literally did just what was mentioned in my original post. (1) Started Web Sharing in the control panels. (2) Uncommented the PHP line in the config file. (3) Stopped and Started the Web Sharing (a couple times). (4) tried a few various PHP files (including info.php, a phptest.php file, IP_ADDRESS.php, and several other php webpages that I have) all located in the Documents folder of the websites file in the library. They SHOULD run from http://localhost/filename.php, but all I get is the source code. So the webserver is finding the files just fine, but doesn't want to run the php.

As for baggage from old OS versions, this is a new MacMini. The hard drive had nothing on it but a fresh install of the OS, so there should be no baggage of any kind.

I haven't tried running PHP from the command. Just through a browser using the localhost. (And I'm at work right now, so I can't try it until I get home) I don't think I've EVER run it from the command. (I assume you mean with the Terminal App). What would I need to do to run it that way?

No, no 3rd party software installed with those names (or parts of names). So far I've only installed some financial software and some office stuff. But nothing that has those words in the names.

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.

Need to restart Apache for PHP to work?

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