Compiling mod_xsendfile for OS X
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.
tags: apache, os x, xsendfile
thanks!
Would you happen to know how to compile it within a MAMP environment. I can’t figure it out.
Thanks
You do need to have Xcode installed first. Then, the command at the bottom of the post should be all that is necessary. That will compile for Apache and PHP as shipped by Apple.
If you’ve installed your own Apache using macports or something, just make sure you point to the macports (or whatever) version of
apxs
.Many thanks! I’ve been searching for this solution for days.
thanks a lot, saved time!
Thank you!
xsendfile mac osx problems installing
Thanks – big help! :)
thanks, this is great info.
were you able to make mod_xsendfile with mongrel cluster proxied?
I haven’t tried mongrel cluster (or any other proxied backend) with mod_xsendfile on OS X, so I can’t say. Let us know if you figure it out.
worked great. used the x_send_file plugin
Thanks! I’ve been looking for this information for awhile now!