Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 12396  / 2 Years ago, wed, october 5, 2022, 6:31:39

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?


More From » 14.04

 Answers
4

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



sudo apt-get remove libapache2-mod-wsgi-py3
sudo apt-get install apache2-dev


2) Install mod_wsgi in virtualenv with pip



. /venv_path/bin/activate
pip install mod_wsgi


3) Install into Apache (system-wide)



sudo /venv_path/bin/mod_wsgi-express install-module
sudo vi /etc/apache2/mods-available/wsgi_express.load /etc/apache2/mods-available/wsgi_express.conf


Content of /etc/apache2/mods-available/wsgi_express.load



LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so


Content of /etc/apache2/mods-available/wsgi_express.conf



WSGIPythonHome /venv_path


4) Enable the module and restart Apache.



sudo a2enmod wsgi_express
sudo service apache2 restart


5) Check that there are no errors in /var/log/apache2/error.log


[#21784] Friday, October 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byishted

Total Points: 469
Total Questions: 113
Total Answers: 113

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;