mod_wsgi and Apache 2.4 on Centos 6.8 - undefined symbol: ap_accept_lock_mech

845 views
Skip to first unread message

O haya

unread,
Nov 7, 2017, 6:49:24 PM11/7/17
to modwsgi
Hi,

I am trying to use WSGI on Apache 2.4.x on CENTOS.

I installed mod_wsgi using yum (yum install mod_wsgi), then I copied the mod_wsgi.so to the Apache modules dir and added a Load Module for mod_wsgi.

However, when I try to start Apache I am getting this:

/apps/apache/bin/apachectl start

httpd: Syntax error on line 152 of /apps/apache/conf/httpd.conf: Cannot load modules/mod_wsgi.so into server: /apps/apache/modules/mod_wsgi.so: undefined symbol: ap_accept_lock_mech

Can anyone tell me why this error is occurring and also, how can I get mod_wsgi to work?

Thanks,
Jim

Graham Dumpleton

unread,
Nov 7, 2017, 6:51:38 PM11/7/17
to mod...@googlegroups.com
I am confused about why you are copying the mod_wsgi.so file anywhere. When you install mod_wsgi using yum, it should put everything in the correct place to start with.

Are you also using Apache install by yum?

Are you also trying to install mod_wsgi using pip?

That error indicates that the Apache installation you are using is much older than the version the mod_wsgi module was compiled for.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

O haya

unread,
Nov 7, 2017, 11:22:52 PM11/7/17
to modwsgi
Hi,

Re. why I was copying the mod_wsgi.so - that was mainly because I was trying to get it into the Apache modules directory.  FYI, I also tried just using the path+file to the mod_wsgi.so in the LoadModule, with same symptoms.

Re. was Apache installed by yum - no, it was built from the Apache 2.4.25 source (originally from a tar.gz from apache.org).

Re. "Are you also trying to install mod_wsgi using pip?" - I am not sure what you mean by that, but as I mentioned on the issues (which I assume you saw), after I failed trying to get the built-mod_wsgi.so (from yum install) working I tried building the mod_wsgi a number of times, including using the system.py approach, the pip install and also the configure/make/make altinstall - all failed.

Re. "the Apache installation you are using is much older than the version the mod_wsgi module was compiled for." - The Apache I was trying was built from the 2.4.25 source.  Current Apache source on apache.org is 2.4.29, so it's not terribly old :).  So are you saying that you think that if I went to say build Apache 2.4.29 that the mod_wsgi from yum would work? 

If so, I would try that, but FYI, our Apaches at work are even older that the 2.4.25, so if we want mod_wsgi for those would an older mod_wsgi (either rpm maybe or source) work with the older Apache?

Thanks,
Jim

Graham Dumpleton

unread,
Nov 7, 2017, 11:28:13 PM11/7/17
to mod...@googlegroups.com
Short answer is you cannot use a mod_wsgi.so from a yum package against anything but the binary distribution of Apache it was built for. You cannot use it with a separate Apache you compiled from source code as how it was built would likely be incompatible.

I can only recommend you start out with the pip method for installation as described in the issue at:


as the easiest way to move forward.

If you cannot get that working as I described such that 'mod_wsgi-express start-server' does something, you need to provide the details of what errors you are getting and what you were doing at that point. I can't guess why you can't install it without seeing the errors.

Also use either the mailing list or the issue, and not both.

Graham

O haya

unread,
Nov 8, 2017, 12:05:49 AM11/8/17
to modwsgi
Hi,

Ok thanks for that info.

I didn't get into detail earlier, but among the attempts that I tried to build mod-wsgi earlier, I actually DID get the "mod_wsgi-express start-server" to work, but then when I tried to add the LoadModule to my Apache 2.4.25, the Apache still failed again, for the same error (the one with "mech" in the error message).  The configuration is now gone (I restored a snapshot).

I have to think about this some more :(...

Jim

O haya

unread,
Nov 8, 2017, 12:17:06 AM11/8/17
to modwsgi
Now I remember, this is what happened when I tried to run "pip3.6 install mod_wsgi":

server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so -L/apps/python-3.6.3/lib -L/apps/python-3.6.3/lib/python3.6/config-3.6m -lpython3.6m
    /usr/bin/ld: /apps/python-3.6.3/lib/libpython3.6m.a(abstract.o): relocation R_X86_64_32S against `_PyObject_NextNotImplemented' can not be used when making a shared object; recompile with -fPIC
    /apps/python-3.6.3/lib/libpython3.6m.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/apps/python-3.6.3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-lsdntr6f/mod-wsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ltr8j01f-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-lsdntr6f/mod-wsgi/


I will try the setup.py next... I think that was the one that worked better...

O haya

unread,
Nov 8, 2017, 12:21:05 AM11/8/17
to modwsgi
Correcting my memory... the "python3.6 setup.py" had the same problem (now I cannot recall how I got the "mod_wsgi-express start-server"  to work):

r/wsgi_apache.o build/temp.linux-x86_64-3.6/src/server/wsgi_metrics.o build/temp.linux-x86_64-3.6/src/server/wsgi_thread.o build/temp.linux-x86_64-3.6/src/server/wsgi_memory.o build/temp.linux-x86_64-3.6/src/server/wsgi_interp.o build/temp.linux-x86_64-3.6/src/server/wsgi_server.o build/temp.linux-x86_64-3.6/src/server/wsgi_stream.o build/temp.linux-x86_64-3.6/src/server/wsgi_daemon.o build/temp.linux-x86_64-3.6/src/server/wsgi_restrict.o build/temp.linux-x86_64-3.6/src/server/wsgi_validate.o build/temp.linux-x86_64-3.6/src/server/wsgi_buckets.o build/temp.linux-x86_64-3.6/src/server/wsgi_logger.o -o build/lib.linux-x86_64-3.6/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so -L/apps/python-3.6.3/lib -L/apps/python-3.6.3/lib/python3.6/config-3.6m -lpython3.6m

O haya

unread,
Nov 8, 2017, 1:08:53 AM11/8/17
to modwsgi
Ok, I am re-reading your page:


When I read before, I couldn't find any "config" directory under my new python dir, but I think that you mean this directory?

[root@apache1 config-3.6m-x86_64-linux-gnu]# pwd
/apps/python-3.6.3/lib/python3.6/config-3.6m-x86_64-linux-gnu
[root@apache1 config-3.6m-x86_64-linux-gnu]# ls -al
total 15644
drwxr-xr-x  2 root root     4096 Nov  8 00:43 .
drwxr-xr-x 35 root root     4096 Nov  8 00:33 ..
-rw-r--r--  1 root root     3302 Nov  8 00:33 config.c
-rw-r--r--  1 root root     1621 Nov  8 00:33 config.c.in
-rwxr-xr-x  1 root root     7122 Nov  8 00:33 install-sh
-rw-r--r--  1 root root 15874060 Nov  8 00:33 libpython3.6m.a
lrwxrwxrwx  1 root root       19 Nov  8 00:43 libpython3.so -> ../../libpython3.so
-rw-r--r--  1 root root    67977 Nov  8 00:33 Makefile
-rwxr-xr-x  1 root root     7521 Nov  8 00:33 makesetup
-rwxr-xr-x  1 root root     2050 Nov  8 00:33 python-config.py
-rw-r--r--  1 root root    10096 Nov  8 00:33 python.o
-rw-r--r--  1 root root    15322 Nov  8 00:33 Setup
-rw-r--r--  1 root root      327 Nov  8 00:33 Setup.config
-rw-r--r--  1 root root       41 Nov  8 00:33 Setup.local

So I re-built Python 3.6.3, with the "--enable-shared" and I think I figured out where the 'config' dir you were referring to (above).

As you can see, I have now added a softlink for libpython3.so but now I am still getting an error, even if run just "python3.6 -V":

[root@apache1 config-3.6m-x86_64-linux-gnu]# python3.6 -V
python3.6: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

So I added another softlink to "libpython3.6m.so.1.0":


[root@apache1 config-3.6m-x86_64-linux-gnu]# ls -al
total 15644
drwxr-xr-x  2 root root     4096 Nov  8 00:56 .
drwxr-xr-x 35 root root     4096 Nov  8 00:33 ..
-rw-r--r--  1 root root     3302 Nov  8 00:33 config.c
-rw-r--r--  1 root root     1621 Nov  8 00:33 config.c.in
-rwxr-xr-x  1 root root     7122 Nov  8 00:33 install-sh
-rw-r--r--  1 root root 15874060 Nov  8 00:33 libpython3.6m.a
lrwxrwxrwx  1 root root       26 Nov  8 00:56 libpython3.6m.so.1.0 -> ../../libpython3.6m.so.1.0
lrwxrwxrwx  1 root root       19 Nov  8 00:43 libpython3.so -> ../../libpython3.so
-rw-r--r--  1 root root    67977 Nov  8 00:33 Makefile
-rwxr-xr-x  1 root root     7521 Nov  8 00:33 makesetup
-rwxr-xr-x  1 root root     2050 Nov  8 00:33 python-config.py
-rw-r--r--  1 root root    10096 Nov  8 00:33 python.o
-rw-r--r--  1 root root    15322 Nov  8 00:33 Setup
-rw-r--r--  1 root root      327 Nov  8 00:33 Setup.config
-rw-r--r--  1 root root       41 Nov  8 00:33 Setup.local
[root@apache1 config-3.6m-x86_64-linux-gnu]#


but I still get an error:

[root@apache1 config-3.6m-x86_64-linux-gnu]# python3.6 -V
python3.6: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

I also added a softlink for libpython3.6m.so but same error??

Then I added "export LD_LIBRARY_PATH=/apps/python-3.6.3/lib/" and then "python3.6 -V" worked.


Is THAT (adding the LD_LIBRARY_PATH necessary)?  

Or, putting that another way, what did I do wrong that caused adding the LD_LIBRARY_PATH to be a necessity?

O haya

unread,
Nov 8, 2017, 1:17:20 AM11/8/17
to modwsgi
Oh oh, problem :(....

I added:

LoadModule wsgi_module "/apps/python-3.6.3/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"

to the new Apache 2.4.29 httpd.conf and then tried to start the Apache and I think that I am back to the same error from before:

[oracle@apache1 bin]$ /apps/httpd-2.4.29/bin/apachectl start
httpd: Syntax error on line 168 of /apps/httpd-2.4.29/conf/httpd.conf: Cannot load /apps/python-3.6.3/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so into server: /apps/python-3.6.3/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so: undefined symbol: ap_accept_lock_mech


:(  ???

Jim

Graham Dumpleton

unread,
Nov 8, 2017, 6:10:12 AM11/8/17
to mod...@googlegroups.com
Do not use code.google.com site for docs. The docs can be found by going to www.modwsgi.org.

For creating a working Python installation read:


Ignore that it talks about Docker. Information still relevant.

Your 'ap_accept_lock_mech' issue is then likely due to using the wrong apxs program for the Apache install you want to use.

Find the 'apxs' program for the Apache you want to use and then run 'pip' as:

    APXS=/some/path/apxs pip install --no-cache-dir mod_wsgi 

You likely have a broken mod_wsgi compiled version cached and need for it to be skipped.

Graham

O haya

unread,
Nov 8, 2017, 6:37:14 PM11/8/17
to modwsgi
Hi,

I got this when I ran that:

export AXPS=/apps/httpd-2.4.29/bin/apxs

pip3.6 install --no-cache-dir mod_wsgi
Requirement already satisfied: mod_wsgi in /apps/python-3.6.3/lib/python3.6/site-packages

Graham Dumpleton

unread,
Nov 8, 2017, 6:38:40 PM11/8/17
to mod...@googlegroups.com
On 9 Nov 2017, at 10:37 am, O haya <jim...@gmail.com> wrote:

Hi,

I got this when I ran that:

export AXPS=/apps/httpd-2.4.29/bin/apxs

pip3.6 install --no-cache-dir mod_wsgi
Requirement already satisfied: mod_wsgi in /apps/python-3.6.3/lib/python3.6/site-packages

Run:

    pip uninstall mod_wsgi

first, or use:

    pip3.6 install --no-cache-dir --update mod_wsgi

O haya

unread,
Nov 8, 2017, 7:03:23 PM11/8/17
to modwsgi
YES!!  That did it and I was able to start Apache 2.4.29 after I added:

LoadModule wsgi_module "/apps/python-3.6.3/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"

to the httpd.conf, and this was even without needing to export LD_LIBRARY_PATH!


Now that I was able to do that, do you think that if I had exported the APXS that I could've used:

python3.6 setup.py install

instead of the "pip3.6 install mod_wsgi"?

The reason I ask is that, at work, I don't think I'll be able to use pip3.6 since it looks like it needs to connect out.

Thanks!

Jim

Graham Dumpleton

unread,
Nov 8, 2017, 7:04:46 PM11/8/17
to mod...@googlegroups.com
Running 'python setup.py install' with APXS environment variable set should also work.

O haya

unread,
Nov 9, 2017, 6:35:34 AM11/9/17
to modwsgi
Cool!  Worked!

O haya

unread,
Nov 9, 2017, 6:38:31 AM11/9/17
to modwsgi
Oops - I have one more question:  I think that in the attempt just made, I had re-built the Apache and used the "--enable-shared" on the Apache configure.  Is that (using --enable-shared) necessary when building the Apache, in order for the mod_wsgi to work with the Apache?  I have to try later tonight, but just was wondering if you knew the answer to that?

The reason for this question is I am pretty sure they don't use "--enable-shared" when they build our Apaches.

Thanks for ALL of your help!

Jim
Jim

Visit this group at https://groups.google.com/group/modwsgi.<br style="font-family:Helvetica;font-size:18px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;te

Graham Dumpleton

unread,
Nov 9, 2017, 6:41:29 AM11/9/17
to mod...@googlegroups.com
The --enable-shared option only relates to Python installation, not Apache. The option would have been ignored by Apache configure script, if it didn't actually error due to the unknown option.

Graham
Reply all
Reply to author
Forward
0 new messages