Solution to: How do I re-install mod_wsgi on Mac after upgrading to OSX Mavericks (10.9)?
Let me preclude this post with saying that I had mod_wsgi working alongside Apache on my Mac 10.8 quite happily for some time. However, after upgrading to 10.9 (OSX Mavericks), my mod_wsgi.so file disappeared from my computer. Also, my httpd.conf file was overwritten as well (the upgrade was nice enough to save a copy before doing so).
I say all this so you know that there are probably more steps to adding the mod_wsgi module from scratch. I did so a long time ago so I don’t remember exactly what they were.
Using Homebrew
If you are unfamiliar with Homebrew, read about it here:
My first attempt was to use Homebrew to install mod_wsgi, then possibly copy the module to the Apache modules folder.
brew install mod_wsgi |
No good. I received this error:
mod_wsgi.c:34:10: fatal error: 'httpd.h' file not found #include "httpd.h" ^ 1 error generated. apxs:Error: Command failed with rc=65536 |
“Make”-ing Manually
Next, I tried copying the mod_wsgi folder that Brew downloaded to /tmp…
cp /Library/Caches/Homebrew/mod_wsgi-3.3.tar.gz /tmp |
…then making manually:
cd /tmp tar -zxvf mod_wsgi-3.3.tar.gz cd mod_wsgi-3.3 ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python make |
Uh-uh:
env: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory
This problem was easily resolved by following the advice here (first answer on page, substitute “9” for “9” in OS version):
Of course, after fixing that issue I wound up looking at the same (first) error message above about missing httpd.h. Looks like I need some Apache source (ugh). Or maybe not. The file exists here:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/apache2/httpd.h
So a search through mod_wsgi.c (v. 3.3) finds this statement at line 34:
#include "httpd.h" |
Changed it to:
#include "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/apache2/httpd.h" |
Then tried “make” again:
Same error. Hey, the compiler uses this include dir:
-I/usr/local/include |
But it doesn’t exist. Maybe if I link it to the apache2 folder under the SDK folder above:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/apache2 /usr/include |
Now I get:
In file included from mod_wsgi.c:34: In file included from /usr/include/httpd.h:43: /usr/include/ap_config.h:25:10: fatal error: 'apr.h' file not found #include "apr.h" ^ 1 error generated. apxs:Error: Command failed with rc=65536 |
I’m on a roll now!
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/apr-1 /usr/include/ |
Then “make” again:
In file included from mod_wsgi.c:34: In file included from /usr/include/httpd.h:43: In file included from /usr/include/ap_config.h:25: /usr/include/apr-1/apr.h:1:10: fatal error: 'Availability.h' file not found #include ^ 1 error generated. apxs:Error: Command failed with rc=65536 |
Argh! This could go on forever. Time to take out the sledgehammer.
Note: If you are the conservative type that doesn’t like to blow up your computer from time to time, the next command *might* not be something you’re into doing.
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/* /usr/include/ |
Hoorah! Got some .so files! Wait, no I don’t! I have .lo, .o, and .slo files. WTF?!
make install |
That was it!
OK, let’s see if she works…
apachectl restart |
Yessir!
That’s my Django app admin interface above. I missed her!
Solution
brew install mod_wsgi cp /Library/Caches/Homebrew/mod_wsgi-3.3.tar.gz /tmp cd /tmp tar -zxvf mod_wsgi-3.3.tar.gz cd mod_wsgi-3.3.tar.gz sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/* /usr/include/ ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python make make install apachectl restart |
Whew!