blogSetomits

Hello

Homebrew で mod_wsgi のインストール

Mac (Snow Leopard) で homebrew を使って mod_wsgi のインストールをしたのでメモ。

mod_wsgi のインストール



$ brew install mod_wsgi
==> Downloading http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/mod_wsgi/3.3 --disable-debug --disabl
==> make install
==> Caveats
NOTE: "brew install -v mod_wsgi" will fail! You must install
in non-verbose mode for this to succeed. Patches to fix this
are welcome.

* You must manually edit /etc/apache2/httpd.conf to load
/usr/local/Cellar/mod_wsgi/3.3/libexec/mod_wsgi.so

* On 10.5, you must run Apache in 32-bit mode:
http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
==> Summary
/usr/local/Cellar/mod_wsgi/3.3: 3 files, 356K, built in 12 seconds


$ ln -s /usr/local/Cellar/mod_wsgi/3.3/libexec/mod_wsgi.so /usr/libexec/apache2/


Apache の設定



$ sudo vi /etc/apache2/httpd.conf

...
# 追加
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
...
...
WSGIScriptAlias /myapp /Users/mits/Sites/aaa.py
...



Apache の再起動


Apache を再起動してログを確認。

$ tail -f /var/log/apache2/error_log

...
[Fri Apr 01 18:22:10 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l
DAV/2 mod_wsgi/3.3 Python/2.7.1 configured -- resuming normal operations


サンプルアプリ



$ cat ~/Sites/aaa.py

def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)

return [output]


プラウザで http://localhost/myapp にアクセスして "Hello World!" と表示されたら OK。
Posted at 18:42 by setomits Comments : 0