Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Just upgraded to Mountain Lion, and wanted to make PHP work on the built-in version of Apache.

share|improve this question
1  
The same way as in previous versions. Check apple.stackexchange.com/questions/23751/… –  Gerry Jul 29 '12 at 8:58

2 Answers 2

up vote 15 down vote accepted
  1. Edit /private/etc/apache2/httpd.conf
  2. Find the line that says LoadModule php5_module libexec/apache2/libphp5.so and uncomment it by editing out the # at the beginning of the line. (Then save the file, obviously.)
  3. Go to Terminal and type sudo apachectl graceful at the console:
share|improve this answer
    
I highly doubt that Apple provides an up-to-date PHP version for this. –  str Dec 8 '12 at 9:55

Probably the easiest way is to use the PHP packages from Liip (a Swiss web development company). It's as easy as running the command from their website and you can choose among PHP 5.3, 5.4, and 5.5. For example:

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4

That way you can also always update to the newest version (that they support), but be careful to backup your custom settings first.

I'm using this installation on Snow Leopard and it works like a charm. On my machine (not sure whether they are the same on Mountain Lion), these paths are often of interest:

  • /usr/local/php5/lib/php.ini
  • /usr/local/php5/lib/php/PEAR/
  • /usr/local/php5/php.d/
  • /usr/local/php5/bin/php
  • /usr/local/php5/bin/pear
  • /usr/local/php5/bin/phpunit

And what I did to make this up-to-date PHP version available in the command line with the command php is this:

sudo ln -is /usr/local/php5/bin/php /usr/bin/php

Hope that helps.

share|improve this answer
    
Hey why was this downvoted? This is a perfectly sensible answer which meets the requirements of the question and, additionally, provides an up-to-date version of PHP. –  str Dec 8 '12 at 10:41
    
The question didn't specify an up-to-date version of PHP, and this solution hasn't been tested on Mountain Lion, which was specified. So it's not very helpful. –  Mike Scott Dec 22 '12 at 12:30
    
Actually, this solution has been tested on Mountain Lion as is specified in the link I posted, just the file paths may not be (but propably are) the same. And since when is it bad to use up-to-date software? –  str Dec 27 '12 at 14:25
    
The bit in your answer saying "not sure whether they are the same on Mountain Lion" suggests otherwise. –  Mike Scott Dec 27 '12 at 14:30
1  
Probably worth mentioning that though this answer doesn't directly apply to the original question, I still found it useful only because it showed up in Google when I was trying to find out whether PEAR and PHPUnit are supplied with the Liip installer. –  Adam-E May 14 '13 at 23:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.