1
votes

Ubuntu16(x64) + Python3.6(installed by anaconda) + Django1.11.3(installed by conda) + Apache2.4.18.

With this configuration__ect/apache2/site-available/000-default.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mblog

WSGIDaemonProcess mblog python-path=/var/www/mblog
WSGIProcessGroup mblog

WSGIScriptAlias / /var/www/mblog/mblog/wsgi.py

<Directory /var/www/mblog/mblog>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>            
</VirtualHost>

and the apache www directory for python project as below:

enter code here/var/www/mblog/(755)
|-- manage.py(755)
|       
|-- mblog(dir 755)
|      `|-- wsgi.py(644)
|       `-- urls.py(644)
|-- templates(dir)
|       `-- *.html(644)

The wsgi.py is configured as below (the files is granted):

import os, sys
sys.path.append('/var/www/mblog/mblog')

# poiting to the project settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mblog.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

After all of these config, the browser display:"500 Internal Server Error"

So I look for the error of /var/log/apache2/error.log as below:

File "/var/www/mblog/mblog/wsgi.py", line 31, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi

I am confused about all of the explain of website explanation but all of these cannot solve this question.

https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/modwsgi/

Could you please give me a hand to solve this problem? Thank you!

1

1 Answers

0
votes

You either haven't told mod_wsgi where the Python virtual environment is that you are using and which Django is installed in, or your mod_wsgi is compiled for a different version of Python than you want to use and which Python is installed in.

Check what mod_wsgi is compiled for by doing what is described in:

For how to set up a Python virtual environment (which is recommended be used), see: