Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 1 down vote accepted

Macports PHP libphp5.so 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/libphp5.so

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/libphp5.so into server: dlopen(/opt/local/apache2/modules/libphp5.so, 10): 
Library not loaded: /opt/local/lib/libaprutil-1.0.dylib\n  Referenced from: /opt/local/apache2/modules/libphp5.so\n  
Reason: Incompatible library version: libphp5.so 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
1  
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

 
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.