views:

281

answers:

5

I had the default Apache2.2 and PHP installation working on my MacBook Pro, but it stopped working at some point. I've read many online articles to try and fix this problem, but none of them have pointed out anything that I am not already doing to get PHP working again. I am completely stumped:

My basic Apache configuration appears to be working properly because I can access both of my virtual hosts in a web browser, but no php code (i.e. phpinfo()) will render. The pages are not throwing any errors, either.

In my apache configuration, I made sure that this line was uncommented: LoadModule php5_module modules/libphp5.so

I also added the line to detect the php MIME type.

A second thing that I tried to do was to install Apache/PHP/MySQL using MacPort. The installation went smoothly, and I stopped my original Apache server and created a separate script to start the 2nd installation. I updated the configuration files, etc., but I am experiencing the same issues.

Secondary Question: Is there any way for me to find out exactly which Apache/PHP/MySQL instance I am running?

Can someone help me overcome this obstacle?

A: 

If you do any changes in .ini or configuration files in apache make sure you restart the apache service.

sudo /usr/sbin/apachectl restart

Try out XAMPP Package . Its available for MAC OSX also. Check out
It takes care of the configuration between APACHE and PHP . So you dont need to worry about the configuring the .ini files.

Webrsk
Thanks for the response: I have been making sure that I restart the service every time I make a change, so I know that is not the issue. I know about the XAMPP package, but I wanted to use a more up-to-date version of PHP. I also wanted to avoid installing another instance of Apache/PHP/MySQL other than what's already there. I think my MacPort attempt already created a second instance.Thanks.
What are your error logs say? run this command from terminal as root:tail -100 /private/var/log/apache2/error_log
Ole Media
A: 

to see your php and mysql version, try php -v and mysql --version from the command line

Do you know at what point this stopped working?

...did you not use php for 2 years...or did this happen overnight?

For now, forget bout MySQL. You can fix that later. If apache is working (meaning you can access an html page), then your PHP is either not properly installed, or apache cannot find it. If "php -v" displays info, then php is properly installed and apache cannot find it. If it displays nothing (or some error), reinstall php. I suggest you do it from source: http://developer.apple.com/internet/opensource/php.html

Tony
A: 

It turns out that this was NOT a server configuration issue at all. It was a text-encoding issue:

I was using Smultron as my text-editor, and for some reason the default text encoding is UTF-16. I changed the encoding of my index.php file to UTF-8, and voila... it worked.

Result:

  • Relieved that I was not misunderstanding the LAMP configuration
  • Annoyed that the real issue was something so trivial
  • Thankful that everything is working :)
A: 

This might not be the solution you're looking for but it works out of the box is XAMPP they have a Mac OSX version and they run out of the box

http://www.apachefriends.org/en/xampp.html

Phill Pafford
A: 

Apple is slow to roll out OS X builds of recent versions of PHP, so if you want the latest version (5.2.9 as I write this) and you don't want to build it from source, you pretty much have to use a third-party build. I recommend Marc Liyanage's Entropy PHP, which is usually very current.

You have to make sure you comment out the LoadModule php5_module line in httpd.conf, though, otherwise Apache won't use the correct PHP. Once you do that, the package should install with no problem and everything should work fine.

Alex Basson