mod_wsgi : mod_wsgi-express error : 'More than

2019-06-09 13:37发布

问题:

I am currently trying to install mod_wsgi in python by following steps in this page https://github.com/GrahamDumpleton/mod_wsgi (seems to be the official page).

After installing with pip install mod_wsgi, I type command mod_wsgi-express start-server to check if it runs.

It seems not running and I have an error :

root@vpsxxxx:/# mod_wsgi-express start-server
Server URL      : http://localhost:8000/
Server Root     : /tmp/mod_wsgi-localhost:8000:0
Server Conf     : /tmp/mod_wsgi-localhost:8000:0/httpd.conf
Error Log       : /tmp/mod_wsgi-localhost:8000:0/error_log
AH00534: apache2: Configuration error: More than one MPM loaded.

As you can see, I am root, but I have the same error If I do mod_wsgi-express start-server wsgi.py --port=80 --user www-data --group www-data.

Any idea ?

Edit : Maybe there's a problem during installation:

/usr/include/python2.7/object.h:822:38: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress]

root@vpsxxxx:~# pip install mod_wsgi
Downloading/unpacking mod-wsgi
Downloading mod_wsgi-4.2.1.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py (path:/tmp/pip_build_root/mod-wsgi/setup.py) egg_info for package mod-wsgi

Downloading/unpacking mod-wsgi-metrics>=1.0.0 (from mod-wsgi)
Downloading mod_wsgi-metrics-1.0.0.tar.gz
Running setup.py (path:/tmp/pip_build_root/mod-wsgi-metrics/setup.py) egg_info for package mod-wsgi-metrics

Installing collected packages: mod-wsgi, mod-wsgi-metrics
Running setup.py install for mod-wsgi
building 'mod_wsgi.server.mod_wsgi-py27' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_daemon.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_daemon.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_stream.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_stream.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_apache.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_apache.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/mod_wsgi.c -o build/temp.linux-x86_64-2.7/src/server/mod_wsgi.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
In file included from /usr/include/python2.7/Python.h:80:0,
                 from src/server/wsgi_python.h:24,
                 from src/server/mod_wsgi.c:22:
src/server/mod_wsgi.c: In function ‘Dispatch_ssl_var_lookup’:
/usr/include/python2.7/object.h:822:38: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress]
 #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
                                      ^
src/server/mod_wsgi.c:5555:9: note: in expansion of macro ‘Py_XINCREF’
         Py_XINCREF(Py_None);
         ^
/usr/include/python2.7/object.h:822:38: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress]
 #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
                                      ^
src/server/mod_wsgi.c:5564:9: note: in expansion of macro ‘Py_XINCREF’
         Py_XINCREF(Py_None);
         ^
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_logger.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_logger.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_convert.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_convert.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_metrics.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_metrics.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_restrict.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_restrict.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_server.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_server.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_validate.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_validate.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_interp.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_interp.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/apache2 -I/usr/include/python2.7 -c src/server/wsgi_buckets.c -o build/temp.linux-x86_64-2.7/src/server/wsgi_buckets.o -I/usr/include/apache2 -I. -I/usr/include/apr-1.0 -I/usr/include -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -pthread
src/server/wsgi_buckets.c: In function ‘wsgi_python_bucket_setaside’:
src/server/wsgi_buckets.c:151:5: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘apr_off_t’ [-Wformat=]
     fprintf(stderr, "start=%lld\n", b->start);
     ^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/server/wsgi_daemon.o build/temp.linux-x86_64-2.7/src/server/wsgi_stream.o build/temp.linux-x86_64-2.7/src/server/wsgi_apache.o build/temp.linux-x86_64-2.7/src/server/mod_wsgi.o build/temp.linux-x86_64-2.7/src/server/wsgi_logger.o build/temp.linux-x86_64-2.7/src/server/wsgi_convert.o build/temp.linux-x86_64-2.7/src/server/wsgi_metrics.o build/temp.linux-x86_64-2.7/src/server/wsgi_restrict.o build/temp.linux-x86_64-2.7/src/server/wsgi_server.o build/temp.linux-x86_64-2.7/src/server/wsgi_validate.o build/temp.linux-x86_64-2.7/src/server/wsgi_interp.o build/temp.linux-x86_64-2.7/src/server/wsgi_buckets.o -o build/lib.linux-x86_64-2.7/mod_wsgi/server/mod_wsgi-py27.so -L/usr/lib -L/usr/lib/python2.7/config -lpython2.7

Installing mod_wsgi-express script to /usr/local/bin
Running setup.py install for mod-wsgi-metrics

Successfully installed mod-wsgi mod-wsgi-metrics
Cleaning up...

Doom.

回答1:

Graham Dumpleton has just updated the repo and dealt with this problem, so please consider updating your python mod_wsgi module which will fix your issue.

The python code running the mod-wsgi module on the backend is trying to add more than one MPM, after already having added one, instead of breaking out of the loop as intended.

This is the code in question

def _mpm_module_defines(modules_directory):
    result = []
    workers = ['event', 'worker', 'prefork']
    for name in workers:
        if os.path.exists(os.path.join(modules_directory,
                'mod_mpm_%s.so' % name)):
            result.append('-DWSGI_MPM_%s_MODULE' % name.upper())
    return result

The code had not taken into account when multiple Apache mods (event and worker and prefork) were installed on the system. The code now has a "break" after the append.