Wednesday, January 26, 2011

"Link" default Apache to MacPorts Apache

Hey there,

I'm on Mac OS X 10.6.4 (the non-Server edition) which has Apache 2 and PHP 5.3 installed by default. However, because I need ImageMagick and all these extensions I would like to somehow 'link' the default Apache server to the one provided by a MacPorts installation.

This means that whenever I enable 'Web Sharing' (sweet name) not the Apache server in /usr but rather the installation in /opt/local should start up. Can I somehow achieve this?

If not, can I use the extensions installed with MacPorts in /opt/local with the default Apache Server in /usr?

Thanks very much in advance for your help.

  • The macports apache comes with a LaunchDaemon file for launchd to use, so the "proper" thing to do is not use the web sharing option and instead run

    sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
    

    That will ensure it starts on system boot and all that goodness. With that in place, just don't touch the one in the sharing panel.


    To answer your question though: Httpd has a compiled in concept of where home is, so just moving the stock httpd out of the way and making a symlink to the macports httpd appears to work to trick the sharing panel to start the macports apache instead of the stock version.

    sudo mv /usr/bin/httpd /usr/bin/httpd-stock
    sudo ln -s /opt/local/apache2/bin/httpd /usr/bin/httpd
    

    Again, that's not the right way to do it really, but it looks like it works, at least on my Leopard box. Didn't try it with Snow Leopard. Hopefully they work similarly and I didn't just lead you down the wrong direction.

    Daniel L : Unfortunately that didn't work for me on Snow Leopard. The httpd file is in a different place and I'm wondering whether it isn't the `apache2ctl` that I need to move. Thanks for your answer, though!

0 comments:

Post a Comment