'Trouble solving "No module named 'encodings'" issue with mod_wsgi
EDIT: I solved it and will update soon. Seems to have helped to compile mod_wsgi from source, and there were other things that also helped.
First of all, I realize that this is a common problem but I think the issue is a mixture of some solutions not working and myself not being an expert on web servers and being a first-time deployer of a Django project, so I probably missed something. Just a nudge in the right direction would be very helpful.
The issue mainly surrounds the Apache package mod_wsgi which facilitates the hosting of the Django application in question here. System-wide installation on my Red Hat Linux Enterprise (7) leads to this error (work server to which I have sudo access). I include anonymized system and error output below. Some important notes:
- The Django project runs in a virtualenv on /var/www.
- Both Python 2.7 and Python 3.6 are running on the system.
- Both mod_wsgi compiled for Python 2 and the newest mod_wsgi (installed with yum; python3-mod_wsgi.x86_64; including httpd-devel required for APXS) are on the system:
/usr/lib64/httpd/modules/mod_wsgi.so
/usr/lib64/httpd/modules/mod_wsgi_python3.so
- The former was first loaded, skipping the second, so I uncommented the relevant line in /etc/httpd/conf.modules.d/10-wsgi.conf, after which the warning disappeared. In /etc/httpd/conf.modules.d/10-wsgi-python3.conf, I have:
<IfModule !wsgi_module>
LoadModule wsgi_module modules/mod_wsgi_python3.so
</IfModule>
(EDIT: I have now uncommented the tag lines but there seems to be no difference.)
- A former iteration (demo) of the project running on Python 2 was running on the server, which was last updated in 2019 (I think). I copied and adapted its configuration file for the current (Python 3) project. Its full contents are at the end of the post.
The Apache error output includes:
...
[Thu Mar 03 23:27:32.639052 2022] [core:notice] [pid 8125] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Mar 03 23:27:32.640505 2022] [wsgi:info] [pid 8199] mod_wsgi (pid=8199): Python home /var/www/myproject/env.
[Thu Mar 03 23:27:32.640547 2022] [wsgi:info] [pid 8199] mod_wsgi (pid=8199): Initializing Python.
[Thu Mar 03 23:27:32.640758 2022] [wsgi:info] [pid 8200] mod_wsgi (pid=8200): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.640796 2022] [wsgi:warn] [pid 8200] (2)No such file or directory: mod_wsgi (pid=8200): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
- The supplied path exists and is to my knowledge correct.
- I used the system-wide Python 3.6 to create the virtualenv (virtualenv -p python3 env; python3.6 bin is included in the env).
- Access permissions seem fine. The project folder belongs to myself and to the same working group that the demo belongs to. I cannot set it to www-data as there is no actual group with this name. However, the log/ directory inside the demo belongs to the group "apache", so I set it as the same in my project. I made sure to "chmod g+s myproject-folder" and, for safety, "chmod o-rwx myproject-folder".
EDIT: I also checked permissions in directories inside the project folders and compared them to those of the demo project. I changed one or two minor things but there was no effect.
Since the demo app has the same name as the main app inside the new Django project, I decided to remove the demo's config file to be safe (it's not really needed anymore).
Assuming that the demo config file was correct (after all, it was working), I have changed only the relevant paths. In the main Apache config file (/etc/httpd/conf/httpd.conf), DocumentRoot is "/var/www/html". It is not set anywhere in the project configs.
Based on online advice, I've tried the following:
- Deleted the virtualenv and reinstalled all requirements.
- Made sure of my paths in Apache project conf file (see below).
Apache thinks it's running, but it doesn't serve the domain.
$ apachectl configtest / apachectl --help / httpd -t (and some others)
AH00526: Syntax error on line 163 of /etc/httpd/conf.d/ssl.conf:
SSLCACertificateFile: file '/etc/letsencrypt/live/my.web.site/fullchain.pem' does not exist or is empty
The specific certificate file does exist and is not empty. EDIT: It was outdated but I managed to update using proxy settings in Bash:
$ sudo bash
# https_proxy=http://proxy.company.xx.xx:0000 certbot
and similarly, with https.
I managed to get the server running for a while last night but I can't replicate the situation yet. Basically it came down to: (1) moving and adding various .conf files to and from /etc/httpd/conf.d and (2) adding a new .conf file containing just the header from the deb.conf file that was removed (based on a suggestion from an ex-colleague):
<VirtualHost *:80>
ServerName my.web.host
Redirect permanent /otherproject/ https://web.host.xx/otherproject/
Redirect permanent /admin/ https://my.web.host/admin/
RewriteEngine on
RewriteCond %{SERVER_NAME} =my.web.host
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
This at some point seemed to have the desired effect but now something is broken again.
I have been reading through the following file meant to help test your mod_wsgi installation: https://modwsgi.readthedocs.io/en/master/user-guides/checking-your-installation.html
For now, I can't check my Apache build information because of the aforementioned syntax error.
Following the page, these are the statically loaded modules:
$ httpd -l
Compiled in modules:
core.c
mod_so.c
http_core.c
I could determine that the value in my LD_LIBRARY_PATH, whether it is set or not, does not change anything, so I left it as is.
httpd -M (list of static and shared modules) leads to the same syntax error.
Next, I am not sure how to test the various different WSGI scripts in the document. Nothing seems to happen if I just run the script in my virtualenv. But I'm sure I'm missing something.
The main Apache configuration file includes all *.confs by default. Below is the project configuration file including error_log as from today.
EDIT: It has been suggested that I should try to disable SELinux temporarily. Setting setenforce to 0 changes the "current mode" to "permissive" instead of "enforcing". This however seems to have no effect. Sestatus output:
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
If you've read this far, many thanks for your time!
Here is my main httpd.conf file.
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
TraceEnable off
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride All
RewriteEngine On
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
Here is the anonymized project conf file.
###<VirtualHost *:*>
# WSGIRestrictEmbedded On
ServerName my.server.name
WSGIDaemonProcess myproject user=apache group=apache threads=3 processes=1 inactivity-timeout=86400 display-name=myproject python-home=/var/www/myproject/env python-path=/var/www/myproject/myproject/project home=/var/www/myproject/myproject/project
WSGIScriptAlias / /var/www/myproject/myproject/project/wsgi.py process-group=myproject
WSGIPythonHome python-home=/var/www/myproject/env
WSGIPythonPath /var/www/myproject/myproject
#Since mod_wsgi 4.1.0:
#WSGIPythonHashSeed random
# for now, see /etc/systemd/system/httpd.service
ErrorLog "/var/log/httpd/myproject-error.log"
CustomLog "/var/log/httpd/myproject-access.log" combined
LogLevel info
<Directory /var/www/myproject/myproject/project>
WSGIProcessGroup myproject
WSGIApplicationGroup %{GLOBAL}
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Alias /myproject/static/ /var/www/myproject/static/
<Directory /var/www/myproject/static>
Allow from all
ExpiresActive on
ExpiresDefault "access plus 4 hours"
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/javascript image/svg+xml application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon
#Don't compress content which is already compressed
SetEnvIfNoCase Request_URI \.(gif|jpe?g|png|swf|woff|woff2) no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</Directory>
###</VirtualHost>
EDIT: Including lines from the error log associated with server restart:
[Thu Mar 03 23:27:32.417162 2022] [core:notice] [pid 8125] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Thu Mar 03 23:27:32.418649 2022] [suexec:notice] [pid 8125] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Mar 03 23:27:32.419201 2022] [ssl:info] [pid 8125] AH01887: Init: Initializing (virtual) servers for SSL
[Thu Mar 03 23:27:32.420456 2022] [ssl:warn] [pid 8125] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Mar 03 23:27:32.420481 2022] [ssl:info] [pid 8125] AH01876: mod_ssl/2.4.6 compiled against Server: Apache/2.4.6, Library: OpenSSL/1.0.2k
[ N 2022-03-03 23:27:32.4531 8129/T1 age/Wat/WatchdogMain.cpp:1366 ]: Starting Passenger watchdog...
[ N 2022-03-03 23:27:32.4786 8132/T1 age/Cor/CoreMain.cpp:1310 ]: Starting Passenger core...
[ N 2022-03-03 23:27:32.4788 8132/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2022-03-03 23:27:32.5057 8132/T1 age/Cor/CoreMain.cpp:985 ]: Passenger core online, PID 8132
[ N 2022-03-03 23:27:32.5106 8132/T7 age/Cor/CoreMain.cpp:641 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ N 2022-03-03 23:27:32.5106 8132/T1 age/Cor/CoreMain.cpp:1216 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ N 2022-03-03 23:27:32.5107 8132/T9 Ser/Server.h:902 ]: [ServerThr.2] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5107 8132/T9 Ser/Server.h:558 ]: [ServerThr.2] Shutdown finished
[ N 2022-03-03 23:27:32.5108 8132/Tb Ser/Server.h:902 ]: [ServerThr.3] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5108 8132/Tb Ser/Server.h:558 ]: [ServerThr.3] Shutdown finished
[ N 2022-03-03 23:27:32.5108 8132/Td Ser/Server.h:902 ]: [ServerThr.4] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5108 8132/Td Ser/Server.h:558 ]: [ServerThr.4] Shutdown finished
[ N 2022-03-03 23:27:32.5108 8132/Tf Ser/Server.h:902 ]: [ServerThr.5] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5108 8132/Tf Ser/Server.h:558 ]: [ServerThr.5] Shutdown finished
[ N 2022-03-03 23:27:32.5108 8132/Th Ser/Server.h:902 ]: [ServerThr.6] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5108 8132/Th Ser/Server.h:558 ]: [ServerThr.6] Shutdown finished
[ N 2022-03-03 23:27:32.5109 8132/Tj Ser/Server.h:902 ]: [ServerThr.7] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5109 8132/Tj Ser/Server.h:558 ]: [ServerThr.7] Shutdown finished
[ N 2022-03-03 23:27:32.5109 8132/Tl Ser/Server.h:902 ]: [ServerThr.8] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5109 8132/Tl Ser/Server.h:558 ]: [ServerThr.8] Shutdown finished
[ N 2022-03-03 23:27:32.5109 8132/T7 Ser/Server.h:902 ]: [ServerThr.1] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5109 8132/T7 Ser/Server.h:558 ]: [ServerThr.1] Shutdown finished
[ N 2022-03-03 23:27:32.5110 8132/Tn Ser/Server.h:902 ]: [ApiServer] Freed 0 spare client objects
[ N 2022-03-03 23:27:32.5110 8132/Tn Ser/Server.h:558 ]: [ApiServer] Shutdown finished
[Thu Mar 03 23:27:32.553124 2022] [lbmethod_heartbeat:notice] [pid 8125] AH02282: No slotmem from mod_heartmonitor
[Thu Mar 03 23:27:32.553753 2022] [socache_shmcb:info] [pid 8125] AH00830: Shared memory socache initialised
[Thu Mar 03 23:27:32.553853 2022] [socache_shmcb:info] [pid 8125] AH00830: Shared memory socache initialised
[Thu Mar 03 23:27:32.553858 2022] [ssl:info] [pid 8125] AH01887: Init: Initializing (virtual) servers for SSL
[Thu Mar 03 23:27:32.555087 2022] [ssl:warn] [pid 8125] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Mar 03 23:27:32.555104 2022] [ssl:info] [pid 8125] AH01876: mod_ssl/2.4.6 compiled against Server: Apache/2.4.6, Library: OpenSSL/1.0.2k
[ N 2022-03-03 23:27:32.5837 8162/T1 age/Wat/WatchdogMain.cpp:1366 ]: Starting Passenger watchdog...
[ N 2022-03-03 23:27:32.6040 8132/T1 age/Cor/CoreMain.cpp:1295 ]: Passenger core shutdown finished
[ N 2022-03-03 23:27:32.6066 8165/T1 age/Cor/CoreMain.cpp:1310 ]: Starting Passenger core...
[ N 2022-03-03 23:27:32.6071 8165/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2022-03-03 23:27:32.6346 8165/T1 age/Cor/CoreMain.cpp:985 ]: Passenger core online, PID 8165
[Thu Mar 03 23:27:32.636458 2022] [wsgi:info] [pid 8199] mod_wsgi (pid=8199): Starting process 'myproject' with uid=48, gid=48 and threads=3.
[Thu Mar 03 23:27:32.639018 2022] [mpm_prefork:notice] [pid 8125] AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips Phusion_Passenger/5.3.7 mod_wsgi/4.7.1 Python/3.6 confi
gured -- resuming normal operations
[Thu Mar 03 23:27:32.639040 2022] [mpm_prefork:info] [pid 8125] AH00164: Server built: Jan 11 2022 00:03:24
[Thu Mar 03 23:27:32.639052 2022] [core:notice] [pid 8125] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Mar 03 23:27:32.640505 2022] [wsgi:info] [pid 8199] mod_wsgi (pid=8199): Python home /var/www/myproject/env.
[Thu Mar 03 23:27:32.640547 2022] [wsgi:info] [pid 8199] mod_wsgi (pid=8199): Initializing Python.
[Thu Mar 03 23:27:32.640758 2022] [wsgi:info] [pid 8200] mod_wsgi (pid=8200): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.640796 2022] [wsgi:warn] [pid 8200] (2)No such file or directory: mod_wsgi (pid=8200): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Mar 03 23:27:32.640842 2022] [wsgi:info] [pid 8200] mod_wsgi (pid=8200): Initializing Python.
[Thu Mar 03 23:27:32.641463 2022] [wsgi:info] [pid 8203] mod_wsgi (pid=8203): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.641497 2022] [wsgi:warn] [pid 8203] (2)No such file or directory: mod_wsgi (pid=8203): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Mar 03 23:27:32.641532 2022] [wsgi:info] [pid 8203] mod_wsgi (pid=8203): Initializing Python.
[Thu Mar 03 23:27:32.644579 2022] [wsgi:info] [pid 8209] mod_wsgi (pid=8209): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.644644 2022] [wsgi:warn] [pid 8209] (2)No such file or directory: mod_wsgi (pid=8209): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Mar 03 23:27:32.644698 2022] [wsgi:info] [pid 8209] mod_wsgi (pid=8209): Initializing Python.
[Thu Mar 03 23:27:32.645167 2022] [wsgi:info] [pid 8204] mod_wsgi (pid=8204): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.645199 2022] [wsgi:warn] [pid 8204] (2)No such file or directory: mod_wsgi (pid=8204): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Mar 03 23:27:32.645235 2022] [wsgi:info] [pid 8204] mod_wsgi (pid=8204): Initializing Python.
[Thu Mar 03 23:27:32.645324 2022] [wsgi:info] [pid 8205] mod_wsgi (pid=8205): Python home python-home=/var/www/myproject/env.
[Thu Mar 03 23:27:32.645354 2022] [wsgi:warn] [pid 8205] (2)No such file or directory: mod_wsgi (pid=8205): Unable to stat Python home python-home=/var/www/myproject/env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
[Thu Mar 03 23:27:32.645390 2022] [wsgi:info] [pid 8205] mod_wsgi (pid=8205): Initializing Python.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
EDIT: error_log as from today.
Sat Mar 05 12:13:49.066660 2022] [core:notice] [pid 4907] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sat Mar 05 12:13:49.067695 2022] [suexec:notice] [pid 4907] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[ N 2022-03-05 12:13:49.1003 4911/T1 age/Wat/WatchdogMain.cpp:1366 ]: Starting Passenger watchdog...
[ N 2022-03-05 12:13:49.1287 4914/T1 age/Cor/CoreMain.cpp:1310 ]: Starting Passenger core...
[ N 2022-03-05 12:13:49.1289 4914/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2022-03-05 12:13:49.1543 4914/T1 age/Cor/CoreMain.cpp:985 ]: Passenger core online, PID 4914
[ N 2022-03-05 12:13:49.1591 4914/T7 age/Cor/CoreMain.cpp:641 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ N 2022-03-05 12:13:49.1592 4914/T1 age/Cor/CoreMain.cpp:1216 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ N 2022-03-05 12:13:49.1592 4914/T9 Ser/Server.h:902 ]: [ServerThr.2] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1593 4914/T9 Ser/Server.h:558 ]: [ServerThr.2] Shutdown finished
[ N 2022-03-05 12:13:49.1593 4914/Tb Ser/Server.h:902 ]: [ServerThr.3] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1593 4914/Tb Ser/Server.h:558 ]: [ServerThr.3] Shutdown finished
[ N 2022-03-05 12:13:49.1593 4914/Td Ser/Server.h:902 ]: [ServerThr.4] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1593 4914/Td Ser/Server.h:558 ]: [ServerThr.4] Shutdown finished
[ N 2022-03-05 12:13:49.1593 4914/Tf Ser/Server.h:902 ]: [ServerThr.5] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1593 4914/Tf Ser/Server.h:558 ]: [ServerThr.5] Shutdown finished
[ N 2022-03-05 12:13:49.1594 4914/Th Ser/Server.h:902 ]: [ServerThr.6] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1594 4914/Th Ser/Server.h:558 ]: [ServerThr.6] Shutdown finished
[ N 2022-03-05 12:13:49.1594 4914/Tj Ser/Server.h:902 ]: [ServerThr.7] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1594 4914/Tj Ser/Server.h:558 ]: [ServerThr.7] Shutdown finished
[ N 2022-03-05 12:13:49.1595 4914/T7 Ser/Server.h:902 ]: [ServerThr.1] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1595 4914/T7 Ser/Server.h:558 ]: [ServerThr.1] Shutdown finished
[ N 2022-03-05 12:13:49.1595 4914/Tn Ser/Server.h:902 ]: [ApiServer] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1595 4914/Tn Ser/Server.h:558 ]: [ApiServer] Shutdown finished
[ N 2022-03-05 12:13:49.1595 4914/Tl Ser/Server.h:902 ]: [ServerThr.8] Freed 0 spare client objects
[ N 2022-03-05 12:13:49.1595 4914/Tl Ser/Server.h:558 ]: [ServerThr.8] Shutdown finished
[Sat Mar 05 12:13:49.195551 2022] [lbmethod_heartbeat:notice] [pid 4907] AH02282: No slotmem from mod_heartmonitor
[Sat Mar 05 12:13:49.195667 2022] [ssl:warn] [pid 4907] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[ N 2022-03-05 12:13:49.2223 4944/T1 age/Wat/WatchdogMain.cpp:1366 ]: Starting Passenger watchdog...
[ N 2022-03-05 12:13:49.2440 4947/T1 age/Cor/CoreMain.cpp:1310 ]: Starting Passenger core...
[ N 2022-03-05 12:13:49.2442 4947/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2022-03-05 12:13:49.2632 4914/T1 age/Cor/CoreMain.cpp:1295 ]: Passenger core shutdown finished
[ N 2022-03-05 12:13:49.2694 4947/T1 age/Cor/CoreMain.cpp:985 ]: Passenger core online, PID 4947
[Sat Mar 05 12:13:49.273445 2022] [mpm_prefork:notice] [pid 4907] AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips Phusion_Passenger/5.3.7 mod_wsgi/4.7.1 Python/3.6 configured -- resuming normal operations
[Sat Mar 05 12:13:49.273476 2022] [core:notice] [pid 4907] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[ E 2022-03-05 12:15:58.5845 4947/T5 age/Cor/SecurityUpdateChecker.h:507 ]: Security update check failed: Couldn't connect to server for https://securitycheck.phusionpassenger.com/v1/check.json (if this error persists check your connection security or try upgrading Passenger) (next check in 24 hours)
[Sat Mar 05 12:18:59.071233 2022] [mpm_prefork:notice] [pid 4907] AH00170: caught SIGWINCH, shutting down gracefully
[ N 2022-03-05 12:19:00.0878 4947/T7 age/Cor/CoreMain.cpp:641 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ N 2022-03-05 12:19:00.0886 4947/T1 age/Cor/CoreMain.cpp:1216 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ N 2022-03-05 12:19:00.0888 4947/T9 Ser/Server.h:902 ]: [ServerThr.2] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Tj Ser/Server.h:902 ]: [ServerThr.7] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Tl Ser/Server.h:902 ]: [ServerThr.8] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/T9 Ser/Server.h:558 ]: [ServerThr.2] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/Tj Ser/Server.h:558 ]: [ServerThr.7] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/Tl Ser/Server.h:558 ]: [ServerThr.8] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/Tc Ser/Server.h:902 ]: [ServerThr.3] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Td Ser/Server.h:902 ]: [ServerThr.4] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Tf Ser/Server.h:902 ]: [ServerThr.5] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/T7 Ser/Server.h:902 ]: [ServerThr.1] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Tc Ser/Server.h:558 ]: [ServerThr.3] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/T7 Ser/Server.h:558 ]: [ServerThr.1] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/Td Ser/Server.h:558 ]: [ServerThr.4] Shutdown finished
[ N 2022-03-05 12:19:00.0888 4947/Th Ser/Server.h:902 ]: [ServerThr.6] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0888 4947/Tf Ser/Server.h:558 ]: [ServerThr.5] Shutdown finished
[ N 2022-03-05 12:19:00.0889 4947/Th Ser/Server.h:558 ]: [ServerThr.6] Shutdown finished
[ N 2022-03-05 12:19:00.0889 4947/Tn Ser/Server.h:902 ]: [ApiServer] Freed 0 spare client objects
[ N 2022-03-05 12:19:00.0889 4947/Tn Ser/Server.h:558 ]: [ApiServer] Shutdown finished
[ N 2022-03-05 12:19:00.1932 4947/T1 age/Cor/CoreMain.cpp:1295 ]: Passenger core shutdown finished
EDIT: The content of the WSGI script is unchanged from the one already present in Django 2.2:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
application = get_wsgi_application()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
