Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If possible, I'd like to retain the default Apache installation and simply direct it to use a different version of PHP built/installed using MacPorts. Is this possible (and if so, is there a straightforward process for setting this up)?

I know Apache wants me to specify the PHP module to load, but its not clear to me how I might have it use a different PHP installation (if thats even possible). Do I need to compile a new apache module that would somehow point to my copy of PHP built with MacPorts? Any clarification on what I need to do would be greatly appreciated!

Update: What about enabling FastCGI and running PHP via that instead of an apache module? I know there are tradeoffs between the two approaches, but would this be a possibility or would I run into similar problems?

share|improve this question
up vote 1 down vote accepted

Macports PHP is usually not compatible with OSX's default Apache system. Here's what happens on my macosxserver.

# /etc/apache2/httpd.conf
LoadModule php5_module /opt/local/apache2/modules/

Attempt to start the server

~> sudo /usr/sbin/apachectl -k start
httpd: Syntax error on line 118 of /private/etc/apache2/httpd.conf: 
Cannot load /opt/local/apache2/modules/ into server: dlopen(/opt/local/apache2/modules/, 10): 
Library not loaded: /opt/local/lib/libaprutil-1.0.dylib\n  Referenced from: /opt/local/apache2/modules/\n  
Reason: Incompatible library version: requires version 5.0.0 or later, but libaprutil-1.0.dylib provides version 4.0.0

You can easily compile PHP to use your default Apache installation, by setting the path to your default apxs.

# In PHP source directory
./configure --with-apxs2=/usr/sbin/apxs

Of course, (re-)compiling PHP might be more work then you wish to inherit. The easist way would be to accept Macport's Apache installation, and adjust your osxserver to use /opt/local/apache2 as your default HTTPD service.

share|improve this answer
I had a feeling this would be the case - thanks for providing some more detail. – Wilco Nov 6 '12 at 18:55
What about running PHP via FastCGI? – Wilco Nov 6 '12 at 18:55
Ah yes!. FastCGI would definitely work. FastCGI wold allow you to run different versions of PHP under different VirtualHost/configurations. – emcconville Nov 6 '12 at 19:32

Your Answer


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.