ページ更新: 2000-01-01 (土) (6957日前)

(2006-12-04新規作成, 2006-08-23 のブックマークより)

Web Server Gateway Interface (WSGI)

目次

[編集]

情報源 #

PEP: 333 Title: Python Web Server Gateway Interface v1.0:

[編集]

mod_wsgi (2008-09-03) #

Apache httpd用のWSGIモジュール。

マニュアル:

バージョンごとの相違点:

Windows用バイナリ: Index of /mod_wsgi

  • version 1.0/1.1/1.2/1.3, 2.0/2.3
  • Python 2.4/2.5
  • Apache 2.0/2.2
[編集]

コンパイル手順の例 (Debian 4.0, mod-wsgi 2.3) #

Apache 1.3, 2.2の混在環境 (discypus.jp)

[編集]

* Apache 1.3 #

apxsをインストールする

# apt-cache search apxs
apache-dev - development kit for the Apache webserver
apache2-prefork-dev - development headers for apache2
apache2-threaded-dev - development headers for apache2
# apt-get install apache-dev
  :
  :
$ svn co http://modwsgi.googlecode.com/svn/tags/mod_wsgi-2.3 mod_wsgi-2.3-apache1.3
A    mod_wsgi-2.3-apache1.3/configure
A    mod_wsgi-2.3-apache1.3/LICENCE
A    mod_wsgi-2.3-apache1.3/configure.ac
A    mod_wsgi-2.3-apache1.3/Makefile-1.X.in
A    mod_wsgi-2.3-apache1.3/Makefile-2.X.in
A    mod_wsgi-2.3-apache1.3/mod_wsgi.c
A    mod_wsgi-2.3-apache1.3/README
 U   mod_wsgi-2.3-apache1.3
リビジョン 1057 をチェックアウトしました。
$ cd mod_wsgi-2.3-apache1.3/

$ ./configure --with-apxs=`which apxs`
checking Apache version... 1.3.34
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile

$ make
/usr/bin/apxs -c -I/usr/include/python2.4 -DNDEBUG   mod_wsgi.c -L/usr/lib/python2.4/config -lpython2.4 -lpthr
ead -ldl  -lutil
gcc -DLINUX=22 -DEAPI -DTARGET="apache" -DHAVE_SET_DUMPABLE -DDB_DBM_HSEARCH=1 -DDEV_RANDOM=/dev/random -DUSE_
HSREGEX -O1  -g -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DSHARED_MODULE -I/usr/include/apache-1
.3 -I/usr/include/python2.4 -DNDEBUG  -c mod_wsgi.c
In file included from /usr/include/python2.4/Python.h:8,
                 from mod_wsgi.c:113:
/usr/include/python2.4/pyconfig.h:851:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/sys/types.h:27,
                 from /usr/include/apache-1.3/ap_config.h:45,
                 from /usr/include/apache-1.3/httpd.h:29,
                 from mod_wsgi.c:34:
/usr/include/features.h:190:1: warning: this is the location of the previous definition
mod_wsgi.c: In function ‘wsgi_server_group’:
mod_wsgi.c:752: warning: unused variable ‘value’
mod_wsgi.c: In function ‘Adapter_output’:
mod_wsgi.c:2332: warning: unused variable ‘rv’
mod_wsgi.c: In function ‘Adapter_file_wrapper’:
mod_wsgi.c:3194: warning: unused variable ‘result’
mod_wsgi.c: In function ‘wsgi_python_child_init’:
mod_wsgi.c:5340: warning: unused variable ‘l’
mod_wsgi.c: In function ‘wsgi_build_environment’:
mod_wsgi.c:6242: warning: unused variable ‘c’
mod_wsgi.c: At top level:
mod_wsgi.c:276: warning: ‘wsgi_daemon_list’ defined but not used
mod_wsgi.c:278: warning: ‘wsgi_parent_pool’ defined but not used
mod_wsgi.c:5638: warning: ‘wsgi_set_restrict_process’ defined but not used
mod_wsgi.c:5671: warning: ‘wsgi_set_process_group’ defined but not used
mod_wsgi.c:5966: warning: ‘wsgi_set_access_script’ defined but not used
mod_wsgi.c:6002: warning: ‘wsgi_set_auth_user_script’ defined but not used
mod_wsgi.c:6038: warning: ‘wsgi_set_auth_group_script’ defined but not used
mod_wsgi.c:6074: warning: ‘wsgi_set_user_authoritative’ defined but not used
mod_wsgi.c:6090: warning: ‘wsgi_set_group_authoritative’ defined but not used
gcc -shared -o mod_wsgi.so mod_wsgi.o -L/usr/lib/python2.4/config -lpython2.4 -lpthread -ldl -lutil
$ sudo make install
/usr/bin/apxs -i -S LIBEXECDIR=/usr/lib/apache/1.3 -n 'mod_wsgi' mod_wsgi.so
cp mod_wsgi.so /usr/lib/apache/1.3/mod_wsgi.so
chmod 755 /usr/lib/apache/1.3/mod_wsgi.so
[編集]

* Apache 2.2 #

(作業中)

apxsをインストールする。今回、Apache2.2は-mpm-worker

# apt-cache search apxs
apache-dev - development kit for the Apache webserver
apache2-prefork-dev - development headers for apache2
apache2-threaded-dev - development headers for apache2
# apt-get install apache2-prefork-dev
  :
  :
$ svn co http://modwsgi.googlecode.com/svn/tags/mod_wsgi-2.3 mod_wsgi-2.3-apache2.2
A    mod_wsgi-2.3-apache2.2/configure
A    mod_wsgi-2.3-apache2.2/LICENCE
A    mod_wsgi-2.3-apache2.2/configure.ac
A    mod_wsgi-2.3-apache2.2/Makefile-1.X.in
A    mod_wsgi-2.3-apache2.2/Makefile-2.X.in
A    mod_wsgi-2.3-apache2.2/mod_wsgi.c
A    mod_wsgi-2.3-apache2.2/README
 U   mod_wsgi-2.3-apache2.2
リビジョン 1057 をチェックアウトしました。
$ cd mod_wsgi-2.3-apache2.2/

$ ./configure --with-apxs=`which apxs2`
checking Apache version... 2.2.3
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile
$ make
/usr/bin/apxs2 -c -I/usr/include/python2.4 -DNDEBUG   mod_wsgi.c -L/usr/lib/python2.4/config -lpython2.4 -lpth
read -ldl  -lutil
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static i486-linux-gnu-gcc -prefer-pic -
DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr
/include/postgresql -I/usr/include/xmltok -pthread     -I/usr/include/apache2  -I/usr/include/apr-1.0   -I/usr
/include/apr-1.0 -I/usr/include/postgresql -I/usr/include/python2.4 -DNDEBUG  -c -o mod_wsgi.lo mod_wsgi.c &&
touch mod_wsgi.slo
In file included from /usr/include/python2.4/Python.h:8,
                 from mod_wsgi.c:113:
/usr/include/python2.4/pyconfig.h:851:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/sys/types.h:27,
                 from /usr/include/apr-1.0/apr.h:113,
                 from /usr/include/apache2/ap_config.h:25,
                 from /usr/include/apache2/httpd.h:43,
                 from mod_wsgi.c:34:
/usr/include/features.h:150:1: warning: this is the location of the previous definition
/usr/share/apr-1.0/build/libtool --silent --mode=link --tag=disable-static i486-linux-gnu-gcc -o mod_wsgi.la
-rpath /usr/lib/apache2/modules -module -avoid-version    mod_wsgi.lo -L/usr/lib/python2.4/config -lpython2.4
-lpthread -ldl -lutil

$ make install
 :
 :

あるPC(Debian 4.0 + Apache 2.2)ではうまくいったけど、discypus.jp (Debian 2.x->3.x->4.0とアップグレードしていて、さらにApache 1.3.xからApache2.2.xにリバースプロキシしている環境) では 502 Proxy Errorが発生したので、Debian4.0 etch-backportsのmod-wsgiに戻した。たぶん Apache 1.3.xとApache2.2.xが混在しているのでconfigureに他のパラメータが必要なのかも (2008-09-06)

[編集]

Phusion Passenger (2010-09-10) #