% port variants mod_wsgi
mod_wsgi has the variants:
   python24: Use Python 2.4
     * conflicts with python25 python26 python31
   python25: Use Python 2.5
     * conflicts with python24 python26 python31
[+]python26: Use Python 2.6
     * conflicts with python24 python25 python31
   python31: Use Python 3.1
     * conflicts with python24 python25 python26
   universal: Build for multiple architectures
% sudo port install mod_wsgi +python25

passengerと同じ感じで設定。

% sudo vi /opt/local/apache2/conf/httpd.conf
(...)
# mod_passenger
Include conf/extra/httpd-passenger.conf

# mod_wsgi
Include conf/extra/httpd-wsgi.conf
(...)
% sudo vi /opt/local/apache2/conf/extra/httpd-wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome  /opt/local

何も書かないとmod_wsgi含むapacheプロセスが立ち上がって勿体無いのでpassengerと同じ様に単独で立ち上がってsocket通信するDaemon modeというので起動。

% sudo vi /opt/local/apache2/conf/extra/httpd-vhosts.conf
(...)
<VirtualHost *:80>
    ServerName hello-mod-wsgi
    DocumentRoot "/Users/komagata/Sites/hello-mod-wsgi"
    WSGIDaemonProcess hello-mod-wsgi processes=2 threads=15
    WSGIScriptAlias / /Users/komagata/Sites/hello-mod-wsgi/hello.wsgi
</VirtualHost>
% sudo vi /etc/hosts
(...)
127.0.0.1       hello-mod-wsgi
(...) 
% vi ~/Sites/hello-mod-wsgi/hello.wsgi
def application(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/plain')])
    return 'Hello, mod_wsgi!'
% sudo /opt/local/apache2/bin/apachectl restart

特に指定しないとlogsディレクトリにapacheの権限で立ち上がるみたいです。

% ls -l /opt/local/apache2/logs/*.sock  
srwx------  1 _www  admin  0 10 27 00:45 /opt/local/apache2/logs/wsgi.815.4.1.sock
http://hello-mod-wsgi/

なるほど

Comments


Option