First: I know there are issues compiling mod_wsgi for MAMP, but I
addressed them by download the MAMP source and compiling a separate
copy of Apache so all of the build and include files were available
during the mod_wsgi build process.
Here's the whole procedure:
1. I installed Python 2.6.4 using the Mac installer disk image from
python.org.
2. I installed MAMP
3. I compiled Apache 2.0.63 from the MAMP source and moved the
relevant files (build and include) into the MAMP folder.
4. I download mod_wsgi-3.1.tar.gz, decompressed, and then ran:
$ ./configure
Which returned the following:
checking for apxs2... no
checking for apxs... /Applications/MAMP/Library/bin/apxs
checking Apache version... 2.0.63
checking for python... /Library/Frameworks/Python.framework/Versions/
2.6/bin/python
configure: creating ./config.status
config.status: creating Makefile
Looks correct, it found MAMP's version of apache, and the latest
version of Python (that's the path to 2.6.4).
I checked the makefile, and the only suspicious thing was that
"LIBEXECDIR = /usr/local/apache2/modules". But that actually makes
sense since I have a symlink in "/usr/local" pointing apache2 to "/
Applications/MAMP/Library/".
5. So I go ahead and run make
$ make
Builds fine, spits out the following:
/Applications/MAMP/Library/bin/apxs -c -I/Library/Frameworks/
Python.framework/Versions/2.6/include/python2.6 -DNDEBUG -Wc,'-arch
ppc' -Wc,'-arch i386' mod_wsgi.c -Wl,-F/Library/Frameworks -framework
Python -u _PyMac_Error -arch ppc -arch i386 -ldl
/Applications/MAMP/Library/build/libtool --silent --mode=compile gcc -
prefer-pic -DAP_HAVE_DESIGNATED_INITIALIZER -DDARWIN -
DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -g -O2 -I/usr/local/
apache2/include -I/Applications/MAMP/Library/include -I/
Applications/MAMP/Library/include -I/Applications/MAMP/Library/include
-arch ppc -arch i386 -I/Library/Frameworks/Python.framework/Versions/
2.6/include/python2.6 -DNDEBUG -c -o mod_wsgi.lo mod_wsgi.c && touch
mod_wsgi.slo
/Applications/MAMP/Library/build/libtool --silent --mode=link gcc -o
mod_wsgi.la -rpath /usr/local/apache2/modules -module -avoid-
version mod_wsgi.lo -Wl,-F/Library/Frameworks -framework Python -u
_PyMac_Error -arch ppc -arch i386 -ldl
6. Now the install
$ sudo make install
Which returns the following:
/Applications/MAMP/Library/bin/apxs -i -S LIBEXECDIR=/usr/local/
apache2/modules -n 'mod_wsgi' mod_wsgi.la
/Applications/MAMP/Library/build/instdso.sh SH_LIBTOOL='/Applications/
MAMP/Library/build/libtool' mod_wsgi.la /usr/local/apache2/modules
/Applications/MAMP/Library/build/libtool --mode=install cp
mod_wsgi.la /usr/local/apache2/modules/
libtool: install: cp .libs/mod_wsgi.so /usr/local/apache2/modules/
mod_wsgi.so
libtool: install: cp .libs/mod_wsgi.lai /usr/local/apache2/modules/
mod_wsgi.la
libtool: install: cp .libs/mod_wsgi.a /usr/local/apache2/modules/
mod_wsgi.a
libtool: install: chmod 644 /usr/local/apache2/modules/mod_wsgi.a
libtool: install: ranlib /usr/local/apache2/modules/mod_wsgi.a
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_wsgi.so
Fair enough. I don't completely understand the note about the LIBDIR
situation. When I look in "/Applications/MAMP/Library/modules",
there's the "mod_wsgi.so" file, so I assume everything's ready to go.
8. In MAMP's "httpd.conf", I add the line "LoadModule wsgi_module
modules/mod_wsgi.so"
That's all for the the configuration.
Then, after firing up MAMP, the Apache logs suggests that everything
is going smoothly:
[Sun Feb 14 16:58:17 2010] [notice] Apache/2.0.63 (Unix) DAV/2
mod_wsgi/3.1 Python/2.6.4 PHP/5.2.11 configured -- resuming normal
operations
[Sun Feb 14 17:03:02 2010] [info] Server built: Dec 12 2009 11:39:11
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2566): Initializing
Python.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2568): Initializing
Python.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2569): Initializing
Python.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2567): Initializing
Python.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2565): Attach
interpreter ''.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2567): Attach
interpreter ''.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2569): Attach
interpreter ''.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2568): Attach
interpreter ''.
[Sun Feb 14 17:03:02 2010] [info] mod_wsgi (pid=2566): Attach
interpreter ''.
But as soon as I make any kind of HTTP request, I get a dropped
connection error in my browser and the following in the Apache logs:
[Sun Feb 14 17:03:29 2010] [notice] child pid 2575 exit signal
Segmentation fault (11)
[Sun Feb 14 17:03:29 2010] [notice] child pid 2568 exit signal
Segmentation fault (11)
[Sun Feb 14 17:03:29 2010] [notice] child pid 2566 exit signal
Segmentation fault (11)
[Sun Feb 14 17:03:29 2010] [info] mod_wsgi (pid=2611): Initializing
Python.
[Sun Feb 14 17:03:29 2010] [info] mod_wsgi (pid=2611): Attach
interpreter ''.
This happens 100% of the time. Again, when I disable the module in
"httpd.conf", everything's fine.
I've Googled very thoroughly, with no luck. It sounds like others have
gotten mod_wsgi working with MAMP, so it shouldn't be a lost cause.
(See: http://www.sitepen.com/blog/2008/05/16/supercharge-mamp/comment-page-1/#comment-87611)
The documentation says that segmentation faults are almost always the
result of conflicts with mod_python... but I've never even installed
mod_python.
I tried mod_wsgi 2.8, which also compiled fine, but also crashes
Apache. I tried manually specifying the LIBEXECDIR as "/Applications/
MAMP/Library/modules" in the makefile and then recompiling. I get the
same crash.
I'm far from an expert with the command line. Perhaps I made a stupid
mistake somewhere? It's hard to know where since the module compiles
without any complaints.
Any help is appreciated.
./configure --disable-framework
The PSF supplied Python versions have been a problem sometimes when
being linked as a framework.
Why are you using such an old Apache version?
Graham
> --
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>
>
[Sun Feb 14 18:11:09 2010] [notice] child pid 8706 exit signal Bus
error (10)
[Sun Feb 14 18:11:09 2010] [notice] child pid 8701 exit signal Bus
error (10)
[Sun Feb 14 18:11:09 2010] [notice] child pid 8700 exit signal Bus
error (10)
On Feb 14, 5:44 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> > (See:http://www.sitepen.com/blog/2008/05/16/supercharge-mamp/comment-page-...)
otool -L /usr/local/apache2/modules/mod_wsgi.so
file /usr/local/apache2/modules/mod_wsgi.so
Graham
/usr/local/apache2/modules/mod_wsgi.so:
/System/Library/Frameworks/Python.framework/Versions/2.6/Python
(compatibility version 2.6.0, current version 2.6.1)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 125.0.0)
(Which is strange since the makefile claimed to be pointing to Python
2.6.4/...)
And running file /usr/local/apache2/modules/mod_wsgi.so returns:
/usr/local/apache2/modules/mod_wsgi.so
/usr/local/apache2/modules/mod_wsgi.so: Mach-O universal binary with 3
architectures
/usr/local/apache2/modules/mod_wsgi.so (for architecture x86_64): Mach-
O 64-bit bundle x86_64
/usr/local/apache2/modules/mod_wsgi.so (for architecture i386): Mach-O
bundle i386
/usr/local/apache2/modules/mod_wsgi.so (for architecture ppc7400):
Mach-O bundle ppc
On Feb 14, 7:36 pm, Graham Dumpleton <graham.dumple...@gmail.com>
./configure --disable-framework
on mod_wsgi.
You might want to make sure you run:
make distclean
before running 'configure' again with different options.
Graham
Here's what I get after running ./configure --disable-framework
checking for apxs2... no
checking for apxs... /Applications/MAMP/Library/bin/apxs
checking Apache version... 2.0.63
checking for python... /Library/Frameworks/Python.framework/Versions/
2.6/bin/python
configure: creating ./config.status
config.status: creating Makefile
The Apache version is old because that's what ships with MAMP.
And here's what the makefile looks like. I've been changing the
LIBEXECDIR to point to MAMP's Apache module folder instead. (/
Applications/MAMP/Library/modules)
# Copyright 2007 GRAHAM DUMPLETON
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
# See the License for the specific language governing permissions and
# limitations under the License.
APXS = /Applications/MAMP/Library/bin/apxs
PYTHON = /Library/Frameworks/Python.framework/Versions/2.6/bin/python
DESTDIR =
LIBEXECDIR = /usr/local/apache2/modules
CPPFLAGS = -I/Library/Frameworks/Python.framework/Versions/2.6/
include/python2.6 -DNDEBUG
CFLAGS = -Wc,'-arch ppc' -Wc,'-arch i386'
LDFLAGS = -L/Library/Frameworks/Python.framework/Versions/2.6/lib -L/
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config
-arch ppc -arch i386
LDLIBS = -lpython2.6 -ldl
all : mod_wsgi.la
mod_wsgi.la : mod_wsgi.c
$(APXS) -c $(CPPFLAGS) $(CFLAGS) mod_wsgi.c $(LDFLAGS) $(LDLIBS)
$(DESTDIR)$(LIBEXECDIR) :
mkdir -p $@
install : all $(DESTDIR)$(LIBEXECDIR)
$(APXS) -i -S LIBEXECDIR=$(DESTDIR)$(LIBEXECDIR) -n 'mod_wsgi'
mod_wsgi.la
clean :
-rm -rf .libs
-rm -f mod_wsgi.o mod_wsgi.la mod_wsgi.lo mod_wsgi.slo mod_wsgi.loT
-rm -f config.log config.status
-rm -rf autom4te.cache
distclean : clean
-rm -f Makefile Makefile.in
realclean : distclean
-rm -f configure
On Feb 14, 7:59 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> ...
>
> read more »
ls -las /Library/Frameworks/Python.framework/Versions/2.6/lib
ls -als /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config
Graham
ls -als /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/config
total 224
0 drwxrwxr-x 12 root admin 408 Oct 27 14:50 .
0 drwxrwxr-x 633 root admin 21522 Feb 4 17:31 ..
88 -rw-rw-r-- 1 root admin 43482 Oct 27 14:51 Makefile
40 -rw-rw-r-- 1 root admin 18265 Oct 27 14:50 Setup
8 -rw-rw-r-- 1 root admin 368 Oct 27 14:50 Setup.config
8 -rw-rw-r-- 1 root admin 41 Oct 27 14:50 Setup.local
8 -rw-rw-r-- 1 root admin 2128 Oct 27 14:50 config.c
8 -rw-rw-r-- 1 root admin 1457 Oct 27 14:50 config.c.in
16 -rwxrwxr-x 1 root admin 7122 Oct 27 14:50 install-sh
8 lrwxr-xr-x 1 root admin 15 Jan 28 01:35 libpython2.6.a -
> ../../../Python
16 -rwxrwxr-x 1 root admin 7431 Oct 27 14:50 makesetup
24 -rw-rw-r-- 1 root admin 11380 Oct 27 14:50 python.o
On Feb 14, 8:19 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> ...
>
> read more »
env | grep DYLD
BTW, why are you using MAMP to begin with, why not just use Apple
Apache? Also, why not just use the Apple supplied Python 2.6. I know
it is only 2.6.1 and not 2.6.4, but for most people the difference
doesn't usually matter.
Graham
env | grep DYLD returns nothing...
I'm using MAMP because it has been convenient in the past to drag and
drop the dev stack from machine to machine (obviously less feasible
with Python apps than for the PHP development the MAMP authors seemed
to have in mind.) I don't *have* to use it, but since others seem to
have succeeded in getting mod_wsgi to work with it, I wanted to give
it a try.
I installed 2.6.4 as a matter of course since I am just getting
started with Python and figured using the latest version was a good
idea. (Maybe not such a good idea?)
Thanks again for all of your time thus far.
On Feb 14, 8:40 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> ...
>
> read more »
For whatever reason, the PSF supplied dmg doesn't want to always work
with -F,-framework. Usually the --disable-framework to force -L/-l
linking works, but not always. I am a bit baffled as to why.
So, try a mod_wsgi configure line of:
./configure --with-python=/usr/bin/python
to force use of Apple supplied Python.
Make sure you take your installed Python out of your PATH else when
you install stuff later you will install for wrong version.
Graham
And it seems like Apache / mod_wsgi is using the Apple supplied Python
(as it should, based on the /usr/bin/python config), since it prints
the following to the log at startup:
[notice] Apache/2.0.63 (Unix) DAV/2 mod_wsgi/3.1 Python/2.6.1 PHP/
5.2.11 configured -- resuming normal operations
On Feb 14, 8:55 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> ...
>
> read more »
/usr/local/apache2/include
/Applications/MAMP/Library/include
Ie., do they have 'httpd.h' and 'apr.h' in them?
I sort of remember that MAMP may not provide header files for
compiling modules against.
As such, when compiling you may be picking up header files from
different Apache installation to server MAMP provides and so stuff is
different and module crashes when started. Am not sure where it would
pick up the wrong header files from, as Apple supplied Apache is in a
subdirectory of /usr/include and location would have to be listed
specifically.
Anyway, check anyway.
Besides running gdb on httpd to track down where crashing, probably
simply suggest you use the Apple supplied Apache as we all Apple
supplied Python. They work now problems at all.
Graham
/usr/local/apache2/ is linked to /Applications/MAMP/Library/, so I
think they're one and the same from the compiler's perspective, and
yes they both have httpd.h and apr.h in them. (Although you're correct
that by default MAMP does not include them, I had to compile Apache
separately from the MAMP source so that these files would be
available. The compiler was throwing errors before I did this. What a
pain...)
As a last-ditch, I tried temporarily replacing the header files in usr/
include with those from the MAMP Apache build, just in case they were
corrupting things. Still no luck, "exit signal Bus error (10)."
I guess I'll move over to the Apple supplied Apache / Python stack.
Too bad, though. Maybe I can grab the working .so file from the guy
who got mod_wsgi working with MAMP (assuming our setups are similar
enough).
Thanks for all your help. Your support of this project is really above
and beyond.
On Feb 14, 9:18 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> ...
>
> read more »