Wednesday, January 11, 2006

mod_python在apache 2.2上安装问题的解决

昨天在一台机器上安装了 apache 2.2 , php 5.1.1, mysql 5.0, postgresql 8.1 ,都编译成功,可是在编译安装mod_python的时候遇到了问题

httpd: Syntax error on line 90 of /usr/local/etc/apache22/httpd.conf:
Cannot load /usr/local/libexec/apache22/mod_python.so into
server: /usr/local/libexec/apache22/mod_python.so: Undefined symbol
"APR_STATUS_IS_SUCCESS"


这是因为 apache 2.2 改写了大量的代码,APR_STATUS_IS_SUCCESS 已经没有在 apache 2.2 中使用了,这时最简单的方法是在源代码 src/filterobject.csrc/connobject.c 中注释掉它,如果你使用的是 mod_python-3.2.5b 也可以使用这个patch:



diff -uNr mod_python-3.2.5b/src/connobject.c mod_python-3.2.5b.new/src/connobject.c
--- mod_python-3.2.5b/src/connobject.c2005-11-12 13:59:35.000000000 -0500
+++ mod_python-3.2.5b.new/src/connobject.c2005-12-03 15:26:27.000000000 -0500
@@ -78,12 +78,6 @@
rc = ap_get_brigade(c->input_filters, bb, mode, APR_BLOCK_READ, bufsize);
Py_END_ALLOW_THREADS;

- if (! APR_STATUS_IS_SUCCESS(rc)) {
- PyErr_SetObject(PyExc_IOError,
- PyString_FromString("Connection read error"));
- return NULL;
- }
-
/*
* loop through the brigade reading buckets into the string
*/
@@ -312,24 +306,17 @@
**
* utility func to make a socket address
*/
-
static PyObject *makesockaddr(struct apr_sockaddr_t *addr)
-{
+{
PyObject *addrobj = makeipaddr(addr);
PyObject *ret = NULL;
if (addrobj) {
- apr_port_t port;
- if(apr_sockaddr_port_get(&port, addr)==APR_SUCCESS) {
- ret = Py_BuildValue("Oi", addrobj, port );
- }
- else {
- PyErr_SetString(PyExc_SystemError,"apr_sockaddr_port_get failure");
- }
+ ret = Py_BuildValue("Oi", addrobj, ntohs(addr->sa.sin.sin_port));
Py_DECREF(addrobj);
}
return ret;
}
-
+
/**
** conn_getattr
**
diff -uNr mod_python-3.2.5b/src/filterobject.c mod_python-3.2.5b.new/src/filterobject.c
--- mod_python-3.2.5b/src/filterobject.c2004-11-25 17:10:52.000000000 -0500
+++ mod_python-3.2.5b.new/src/filterobject.c2005-12-03 14:20:29.000000000 -0500
@@ -178,11 +178,6 @@
APR_BLOCK_READ, self->readbytes);
Py_END_ALLOW_THREADS;

- if (!APR_STATUS_IS_EAGAIN(self->rc) && !APR_STATUS_IS_SUCCESS(self->rc)) {
- PyErr_SetObject(PyExc_IOError,
- PyString_FromString("Input filter read error"));
- return NULL;
- }
}

/*
diff -uNr mod_python-3.2.5b/test/test.py mod_python-3.2.5b.new/test/test.py
--- mod_python-3.2.5b/test/test.py2005-11-14 13:09:49.000000000 -0500
+++ mod_python-3.2.5b.new/test/test.py2005-12-03 14:23:45.000000000 -0500
@@ -242,9 +242,9 @@
PythonOption('PythonOptionTest sample_value'),
DocumentRoot(DOCUMENT_ROOT),
LoadModule("python_module %s" % MOD_PYTHON_SO),
- IfModule("!mod_auth.c",
- LoadModule("auth_module %s" %
- quoteIfSpace(os.path.join(modpath, "mod_auth.so")))))
+ IfModule("!mod_auth_basic.c",
+ LoadModule("auth_basic_module %s" %
+ quoteIfSpace(os.path.join(modpath, "mod_auth_basic.so")))))

f = open(CONFIG, "w")
f.write(str(s))

No comments:

Post a Comment