无法在ubuntu上为django安装wsgi_mod-3.3

时间:2013-12-18 00:29:29

标签: django apache ubuntu

我正在尝试使用Apache2在Ubuntu上运行我的Web服务器,以便运行使用Django构建的站点。在official django docs之后,我成功运行了apache服务器来运行django应用程序。但是,我使用的是Python 3.3,当我安装mod_wsgi时,它被配置为错误的python版本,因此应用程序获得500内部服务器错误,Apache错误日志显示ImportError: No module named django.core.wsgi

我正在尝试使用以下终端命令安装为Python 3.3构建的mod_wsgi。

mkdir ~/sources
cd ~/sources
wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz 
tar xvfz mod_wsgi-3.3.tar.gz
cd mod_wsgi-3.3
./configure
make
sudo make install

然而,当我到达make时,我收到错误,我无法继续。

~/sources/mod_wsgi-3.3$ make
/usr/bin/apxs2 -c -I/usr/include/python2.7 -DNDEBUG -D_FORTIFY_SOURCE=2   mod_wsgi.c -    L/usr/lib -L/usr/lib/python2.7/config  -lpython2.7 -lpthread -ldl  -lutil -lm
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static x86_64-    linux-gnu-gcc -std=gnu99 -prefer-pic -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4     -Wformat -Werror=format-security -Wformat-security -D_FORTIFY_SOURCE=2 -fno-strict-aliasing  -    D_FORTIFY_SOURCE=2   -DLINUX -D_REENTRANT -D_GNU_SOURCE  -pthread  -I/usr/include/apache2  -    I/usr/include/apr-1.0   -I/usr/include/apr-1.0 -I/usr/include -I/usr/include/python2.7 -    DNDEBUG -D_FORTIFY_SOURCE=2  -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
mod_wsgi.c: In function 'wsgi_process_socket':
mod_wsgi.c:10095:37: error: 'conn_rec' has no member named 'remote_addr'
 if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, sock))
                                 ^
mod_wsgi.c:10103:27: error: 'conn_rec' has no member named 'remote_ip'
 apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
                       ^
mod_wsgi.c:10103:41: error: 'conn_rec' has no member named 'remote_addr'
 apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
                                     ^
mod_wsgi.c: In function 'wsgi_hook_daemon_handler':
mod_wsgi.c:12742:18: error: 'conn_rec' has no member named 'remote_ip'
 r->connection->remote_ip = (char *)apr_table_get(r->subprocess_env,
              ^
mod_wsgi.c: In function 'Auth_environ':
mod_wsgi.c:13262:10: error: 'conn_rec' has no member named 'remote_ip'
 if (c->remote_ip) {
      ^
mod_wsgi.c:13263:18: error: 'conn_rec' has no member named 'remote_ip'
     value = c->remote_ip;
              ^
mod_wsgi.c:13295:14: error: 'conn_rec' has no member named 'remote_addr'
 rport = c->remote_addr->port;
          ^
mod_wsgi.c: In function 'wsgi_hook_access_checker':
mod_wsgi.c:14395:29: error: 'conn_rec' has no member named 'remote_ip'
     host = r->connection->remote_ip;
                         ^
mod_wsgi.c: At top level:
mod_wsgi.c:14697:5: warning: initialization from incompatible pointer type [enabled by default]
 &wsgi_check_authorization,
 ^
mod_wsgi.c:14697:5: warning: (near initialization for     'wsgi_authz_provider.check_authorization') [enabled by default]
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wsgi.la] Error 1

从错误消息看,当我想要3.3时,它似乎正在尝试使用python2.7,虽然我不知道这是错误的原因。 我认为这会源于make,因为它说它检查了/usr/bin/python中的python而不是/usr/bin/python3.3

如何让它正常工作?

我正在运行apache2,django1.6,ubuntu 13.10

修改

我可以通过运行./configure./configure --with-python=/usr/bin/python3.3工作,但现在我得到了一个不同的错误:

~/sources/mod_wsgi-3.3$ make
/usr/bin/apxs2 -c -I/usr/include/python3.3m -DNDEBUG   mod_wsgi.c -L/usr/lib -    L/usr/lib/python3.3/config  -lpython3.3 -lpthread -ldl  -lutil -lm
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static x86_64-    linux-gnu-gcc -std=gnu99 -prefer-pic -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4     -Wformat -Werror=format-security -Wformat-security -D_FORTIFY_SOURCE=2 -fno-strict-aliasing  -    D_FORTIFY_SOURCE=2   -DLINUX -D_REENTRANT -D_GNU_SOURCE  -pthread  -I/usr/include/apache2  -    I/usr/include/apr-1.0   -I/usr/include/apr-1.0 -I/usr/include -I/usr/include/python3.3m -    DNDEBUG  -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
mod_wsgi.c:135:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                   ^
compilation terminated.
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wsgi.la] Error 1

1 个答案:

答案 0 :(得分:0)

您可以尝试安装the ubuntu package

而不是自己编译python3.3的mod_wsgi