【问题标题】:can't install wsgi_mod-3.3 for django on ubuntu无法在 ubuntu 上为 django 安装 wsgi_mod-3.3
【发布时间】:2013-12-18 00:29:28
【问题描述】:

我正在尝试使用 Apache2 让我的 Web 服务器在 Ubuntu 上运行,以便运行我使用 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而不是/usr/bin/python3.3中检查了python。

我怎样才能让它正常工作?

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

编辑

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

~/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

【问题讨论】:

  • 要修复 Python.h 错误,您需要使用 sudo apt-get install python3-dev 安装 python 头文件。

标签: django apache ubuntu


【解决方案1】:

您可以尝试安装the ubuntu package,而不是自己为python3.3编译mod_wsgi

【讨论】:

    猜你喜欢
    • 2013-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 1970-01-01
    • 2018-04-06
    • 2018-07-27
    • 2018-12-03
    相关资源
    最近更新 更多