我想在我自己的Apache服务器上运行我的Django应用程序,但是当我使用以下配置文件时,我收到以下错误。 RuntimeError: populate() isn't reentrant
我没有使用virtualenv。 Django版本:1.10.4
修改 我解决了这个问题。 对于我的ubuntu 16.04服务器:
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
Wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yuyyu.settings")
application = get_wsgi_application()
Apache Conf。文件:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName example.com
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
Alias /static /var/www/html/yuyyu/static
<Directory /var/www/html/yuyyu/static>
Require all granted
</Directory>
<Directory /var/www/html/yuyyu/yuyyu>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess yuyyu python-path=/var/www/html/yuyyu:/usr/local/lib/python2.7/dist-packages/
WSGIProcessGroup yuyyu
WSGIScriptAlias / /var/www/html/yuyyu/yuyyu/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
Apache Error.log:
[Fri Dec 02 20:26:53.294689 2016] [:error] [pid 8930] [remote SERVER_IP:4207] mod_wsgi (pid=8930): Target WSGI script '/var/www/html/yuyyu/yuyyu/wsgi.py' cannot be loaded as Python module.
[Fri Dec 02 20:26:53.294766 2016] [:error] [pid 8930] [remote SERVER_IP:4207] mod_wsgi (pid=8930): Exception occurred processing WSGI script '/var/www/html/yuyyu/yuyyu/wsgi.py'.
[Fri Dec 02 20:26:53.294800 2016] [:error] [pid 8930] [remote SERVER_IP:4207] Traceback (most recent call last):
[Fri Dec 02 20:26:53.294863 2016] [:error] [pid 8930] [remote SERVER_IP:4207] File "/var/www/html/yuyyu/yuyyu/wsgi.py", line 5, in <module>
[Fri Dec 02 20:26:53.294870 2016] [:error] [pid 8930] [remote SERVER_IP:4207] application = get_wsgi_application()
[Fri Dec 02 20:26:53.294904 2016] [:error] [pid 8930] [remote SERVER_IP:4207] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Dec 02 20:26:53.294912 2016] [:error] [pid 8930] [remote SERVER_IP:4207] django.setup(set_prefix=False)
[Fri Dec 02 20:26:53.294939 2016] [:error] [pid 8930] [remote SERVER_IP:4207] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
[Fri Dec 02 20:26:53.294947 2016] [:error] [pid 8930] [remote SERVER_IP:4207] apps.populate(settings.INSTALLED_APPS)
[Fri Dec 02 20:26:53.294971 2016] [:error] [pid 8930] [remote SERVER_IP:4207] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Dec 02 20:26:53.294977 2016] [:error] [pid 8930] [remote SERVER_IP:4207] raise RuntimeError("populate() isn't reentrant")
[Fri Dec 02 20:26:53.294998 2016] [:error] [pid 8930] [remote SERVER_IP:4207] RuntimeError: populate() isn't reentrant
[Fri Dec 02 20:26:53.800485 2016] [:error] [pid 8930] [remote SERVER_IP:4463] mod_wsgi (pid=8930): Target WSGI script '/var/www/html/yuyyu/yuyyu/wsgi.py' cannot be loaded as Python module.
[Fri Dec 02 20:26:53.800643 2016] [:error] [pid 8930] [remote SERVER_IP:4463] mod_wsgi (pid=8930): Exception occurred processing WSGI script '/var/www/html/yuyyu/yuyyu/wsgi.py'.
[Fri Dec 02 20:26:53.800767 2016] [:error] [pid 8930] [remote SERVER_IP:4463] Traceback (most recent call last):
[Fri Dec 02 20:26:53.800946 2016] [:error] [pid 8930] [remote SERVER_IP:4463] File "/var/www/html/yuyyu/yuyyu/wsgi.py", line 5, in <module>
[Fri Dec 02 20:26:53.801001 2016] [:error] [pid 8930] [remote SERVER_IP:4463] application = get_wsgi_application()
[Fri Dec 02 20:26:53.801118 2016] [:error] [pid 8930] [remote SERVER_IP:4463] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Dec 02 20:26:53.801185 2016] [:error] [pid 8930] [remote SERVER_IP:4463] django.setup(set_prefix=False)
[Fri Dec 02 20:26:53.801296 2016] [:error] [pid 8930] [remote SERVER_IP:4463] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
[Fri Dec 02 20:26:53.801365 2016] [:error] [pid 8930] [remote SERVER_IP:4463] apps.populate(settings.INSTALLED_APPS)
[Fri Dec 02 20:26:53.801474 2016] [:error] [pid 8930] [remote SERVER_IP:4463] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Dec 02 20:26:53.801559 2016] [:error] [pid 8930] [remote SERVER_IP:4463] raise RuntimeError("populate() isn't reentrant")
[Fri Dec 02 20:26:53.801656 2016] [:error] [pid 8930] [remote SERVER_IP:4463] RuntimeError: populate() isn't reentrant
当我去https://SERVER_IP时,我收到此消息:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.7 (Ubuntu) Server at SERVER_IP Port 443