macにインストールしようとしたら若干勝手が違ったので、メモ
まず、macportsのmod_wsgiの依存関係を調べてみると、、、
$ port info mod_wsgi
Warning: port definitions are more than two weeks old, consider using selfupdate
mod_wsgi @3.3 (www, python)
Variants: python24, python25, [+]python26, python27, python31, universal
Description: The mod_wsgi module is written in C code directly against the internal Apache and Python application programming interfaces. As such, for
hosting WSGI applications in conjunction with Apache it has a lower memory overhead and performs better than existing WSGI adapters for
mod_python or alternative FASTCGI/SCGI/CGI based solutions.
Homepage: http://www.modwsgi.org/
Library Dependencies: apache2, python26
Platforms: darwin
License: Apache
Maintainers: nomaintainer@macports.org
依存関係等にpython3.3が含まれていない。つまりpython3.3を使ってwsgiを動かすためには、macportsでmod_wsgiが動かない可能性がある。
ので、さくらVPSの時と同様、自分でビルド&インストールをする。
1回目
(python33)
$ wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
$ tar zxvf mod_wsgi-3.4.tar.gz
$ cd mod_wsgi-3.4
$ ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/opt/local/bin/python3.3
checking Apache version... 2.2.22
configure: creating ./config.status
config.status: creating Makefile
$ make
(略)
$ sudo make install
(略)
$
インストールまでは問題ないみたい。ところが……
(LoadModuleをhttpd.confに追加済み)
$ sudo /opt/local/apache2/bin/apachectl -S
httpd: Syntax error on line 119 of /opt/local/apache2/conf/httpd.conf: Cannot load /opt/local/apache2/modules/mod_wsgi.so into server: dlopen(/opt/local/apache2/modules/mod_wsgi.so, 10): Symbol not found: __Py_FalseStruct\n Referenced from: /opt/local/apache2/modules/mod_wsgi.so\n Expected in: flat namespace\n in /opt/local/apache2/modules/mod_wsgi.so
mod_wsgi.soのロードが出来ない。Googleしてみると、ここを見つけた。
Provide the output from running:
otool -L /usr/libexec/apache2/mod_wsgi.so
$ otool -L /opt/local/apache2/modules/mod_wsgi.so
/opt/local/apache2/modules/mod_wsgi.so:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
どうもmod_wsgi.soがPython2.7を見ているっぽい。見つけたページを読み進めるとFramework無効化が必要らしいので……
2回目
一応pythonのパスもmacportsのフルパスにしておく
(python33)$ ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/opt/local/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 --disable-framework
checking Apache version... 2.2.22
configure: creating ./config.status
config.status: creating Makefile
$ make
(略)
$ sudo make install
(略)
$
(LoadModuleをhttpd.confに追加済み)
$ otool -L /opt/local/apache2/modules/mod_wsgi.so
/opt/local/apache2/modules/mod_wsgi.so:
/opt/local/Library/Frameworks/Python.framework/Versions/3.3/Python (compatibility version 3.3.0, current version 3.3.0)
/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
$ sudo /opt/local/apache2/bin/apachectl -S
(略)
Syntax OK
今度は正しく認識してくれた。