Building mod_xsendfile on Mac OS X

Copying this here, in case it ever disappears and I need it again.

Today I needed to compile mod_xsendfile for OS X on Intel. The standard command for this,

apxs -cia mod_xsendfile.c

resulted in a module that was for i386 only.

Apache on Leopard (untested on Tiger) doesn’t appreciate this, throwing this error:

4/7/08 5:08:08 PM org.apache.httpd[ 15990] httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_xsendfile.so into server: dlopen(/usr/libexec/apache2/mod_xsendfile.so, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/mod_xsendfile.so: mach-o, but wrong architecture

Turns out the solution is pretty simple. Just change the command to apxs to this:

apxs -cia -Wc,"-arch x86_64 -arch ppc -arch i386 -arch ppc64" -Wl,"-arch x86_64 -arch ppc -arch i386 -arch ppc64" mod_xsendfile.c

This will generate a fat-binary for all four current Mac architectures.

This entry was posted in General. Bookmark the permalink.

8 Responses to Building mod_xsendfile on Mac OS X

  1. Perry Smith says:

    Thanks! You seem to have gotten to this point about a week before I did.

  2. Justin says:

    Hi.. I’ve been fighting this with and just came across your post. i ran the command like you have it verbatim and get the follwoing error. Any ideas what I may be doing wrong?

    /usr/local/zend/apache2/build-1/libtool –silent –mode=compile gcc -prefer-pic -O2 -pipe -g -fno-common -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -I/usr/local/pcre-7.8/include -I/usr/local/zend/apache2/include -I/usr/local/zend/apache2/include/apr-1 -I/usr/local/zend/apache2/include/apr-1 ”-arch -c -o mod_xsendfile.lo mod_xsendfile.c && touch mod_xsendfile.slo
    i686-apple-darwin10-gcc-4.2.1: ”-arch: No such file or directory
    apxs:Error: Command failed with rc=65536

  3. Ryan says:

    Hey Justin – my guess is that if you copy/pasted into the terminal you’ve picked up the stylized quotation marks – I’ve updated the block to be copy/pastable, so give it another try and let me know!

  4. Anlek says:

    I’m having the same issue:
    apxs:Error: Command failed with rc=65536

    I’ve ensured the quotes were correct.

  5. Ryan says:

    Hey Anlek, Sorry – haven’t run across that one myself. There’s a fair bit on it if you google that message however. Good luck!

  6. Nathan says:

    Running the command as root fixed the rc=65536 error for me.

  7. Mario says:

    Compiles fine, apache starts but delivers empty pages only.
    Error log says:

    [Tue Jul 06 16:44:08 2010] [notice] child pid 37721 exit signal Bus error (10)

    Everything works fine again if i disable the module in httpd.conf

    PS: Using Zend Server CE

  8. Ryan says:

    Sorry Mario, no ideas for you on that one.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>