On Ubuntu 14.04, using Apache2 with package libapache2-mod-wsgi-py3 installed gives errors in /var/log/apache2/error.log
The way to reproduce is straightforward :
sudo apt-get install apache2
sudo service apache2 restart
# /var/log/apache2/error.log is "clean"
sudo apt-get install libapache2-mod-wsgi-py3
sudo service apache2 restart
/var/log/apache2/error.log gives the following error :
[Mon Jan 05 16:51:53.641332 2015] [:error] [pid 3141:tid 140703516379008] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Mon Jan 05 16:51:53.643563 2015] [:error] [pid 3141:tid 140703516379008] Traceback (most recent call last):
[Mon Jan 05 16:51:53.643633 2015] [:error] [pid 3141:tid 140703516379008] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Mon Jan 05 16:51:53.644350 2015] [:error] [pid 3141:tid 140703516379008] assert tlock is not None
[Mon Jan 05 16:51:53.643449 2015] [:error] [pid 3140:tid 140703516379008] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>
[Mon Jan 05 16:51:53.644456 2015] [:error] [pid 3140:tid 140703516379008] Traceback (most recent call last):
[Mon Jan 05 16:51:53.644514 2015] [:error] [pid 3140:tid 140703516379008] File "/usr/lib/python3.4/threading.py", line 1288, in _shutdown
[Mon Jan 05 16:51:53.645052 2015] [:error] [pid 3140:tid 140703516379008] assert tlock is not None
[Mon Jan 05 16:51:53.645119 2015] [:error] [pid 3141:tid 140703516379008] AssertionError:
[Mon Jan 05 16:51:53.647513 2015] [:error] [pid 3140:tid 140703516379008] AssertionError:
How to get it work error-free?
Ubuntu 14.04 comes with mod_wsgi 3.4. According to https://code.djangoproject.com/ticket/22948#comment:2 we need to use mod_wsgi version 4.2+ for Python 3.4.
The best way to install mod_wsgi to the latest version is to get it with pip (can be in virtualenv) and then install its module to apache system-wide. In my case I use virtualenv set in
/venv_path
.1) Remove problematic package and install dependency
2) Install mod_wsgi in virtualenv with pip
3) Install into Apache (system-wide)
Content of
/etc/apache2/mods-available/wsgi_express.load
Content of
/etc/apache2/mods-available/wsgi_express.conf
4) Enable the module and restart Apache.
5) Check that there are no errors in
/var/log/apache2/error.log
Just wanted to add something to the accepted answer provided by samb.
The actual lines of config that you need to add to the module config are the ones outputted by the
mod_wsgi-express install-module
command (this wasn't explicit in the accepted answer).Also, in my case (and according to the mod_wsgi pkg documentation - probably this wasn't the case when the accepted answer was written) I didn't get any
wsgi_express.*
files inmods-available
, but onlywsgi.*
, and it was sufficient to replace thewsgi.load
file with the new config by runningOf course, this would overwrite the whole file, so watch out in case you happen to have any more directives in it.