Monday, May 12, 2008

FastCGI on OS/X Leopard

A post for posterity.

OK, so you want to run FastCGI on OS/X 10.5, how does that work? If you've just followed the directions and used your usual UNIX skillz, you'll have dead-ended on this odd error:

httpd: Syntax error on line 115 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_fastcgi.so into server: dlopen(/usr/libexec/apache2/mod_fastcgi.so, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/mod_fastcgi.so: mach-o, but wrong architecture

This is the architecture of your DSO not matching the x86_64 architecture of the build shipped with OS/X. So we must build with the correct flags in place.

Here's the steps from scratch.
curl http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz > mod_fastcgi-2.4.6.tar.gz
tar xvfz mod_fastcgi-2.4.6.tar.gz
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
Now edit Makefile and change top_dir to /usr/share/httpd and add a line CGLAGS=-arch x86_64.
make
cp .lib/mod_fastcgi.so /usr/libexec/apache2
Now edit /private/etc/apache2/httpd.conf and add a line LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so. Run apachectl restart and you are now loaded. You'll need to enable FastCGI for your applications as described in the documentation.
 

6 comments:

Stephan said...

I haven't tested it, but you could have used darwinports to build from source: http://mod_fastcgi.darwinports.com/

Paul Ramsey said...

True, but they I'd have to give up my Apple-installed Apache for the one from ports. My fanboi heart wouldn't allow it :)

mentalhome said...

cp .lib/mod_fastcgi.so /usr/libexec/apache2

results in no such file or directory. All the above has been executed. In which directory should the file reside? The are a .o and a .slo though in the mod_fastcgi dir.

willard

Dane said...

$ sudo cp .libs/mod_fastcgi.so /usr/libexec/apache2

works for me mentalhome, so try changing .lib to .libs

Paul, thanks for the writeup!

Dane said...

Should be:

CFLAGS = -arch x86_64

not

CGLAGS=-arch x86_64

subsystem7 said...

Hey Paul, take a few minutes to implement dane's changes, would save a little time. Thanks for the post btw.

About Me

My Photo
Paul Ramsey
Victoria, British Columbia, Canada
View my complete profile

Followers

Blog Archive

Labels