I'm trying to deploy my first, simple django website. I have an VPS with Ubuntu 14.07 Server, Apache 2.4.7 with mod_wsgi.
So, i added this vhost:
<VirtualHost *:80>
ServerName api.XXX.net
ServerAdmin webmaster@XXX.net
DocumentRoot /var/www/XXX.net/api
WSGIScriptAlias / /var/www/XXX.net/api/backgrounds-apps-server/XXX/index.wsgi
WSGIDaemonProcess api.XXX.net processes=2 threads=15 python-path=/var/www/XXX.net/api:/var/www/XXX.net/api/lib/python3.4/site-packages
WSGIProcessGroup api.XXX.net
<Directory /var/www/XXX.net/api/backgrounds-apps-server>
Order allow,deny
Allow from all
</Directory>
Alias /static/ /var/www/XXX.net/api/backgrounds-apps-server/XXX/static/
<Location "/static/">
Options -Indexes
</Location>
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/api_XXX_error.log
CustomLog ${APACHE_LOG_DIR}/api_XXX_access.log combined
</VirtualHost>
and my index.wsgi:
import os, sys, site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/var/www/XXX.net/api/lib/python3.4/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/var/www/XXX.net/api/backgrounds-apps-server')
sys.path.append('/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "movies_wallpaper.settings")
#Activate your virtual environment
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
But when I'm trying to load the page I'm getting 500 Error. In apache log we can see this:
[Mon Oct 06 16:27:42.625220 2014] [:info] [pid 3050] mod_wsgi (pid=3050): Adding '/var/www/XXX.net/api' to path.
[Mon Oct 06 16:27:42.625433 2014] [:info] [pid 3050] mod_wsgi (pid=3050): Adding '/var/www/XXX.net/api/lib/python3.4/site-packages' to path.
[Mon Oct 06 16:27:42.626344 2014] [:info] [pid 3050] [remote 188.121.29.164:61055] mod_wsgi (pid=3050, process='api.XXX.net', application='api.XXX.net|'): Loading WSGI script '/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper/index.wsgi'.
[Mon Oct 06 14:27:43.418048 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] mod_wsgi (pid=3050): Target WSGI script '/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper/index.wsgi' cannot be loaded as Python module.
[Mon Oct 06 14:27:43.418082 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] mod_wsgi (pid=3050): Exception occurred processing WSGI script '/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper/index.wsgi'.
[Mon Oct 06 14:27:43.418106 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] Traceback (most recent call last):
[Mon Oct 06 14:27:43.418128 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper/index.wsgi", line 14, in <module>
[Mon Oct 06 14:27:43.418189 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] application = get_wsgi_application()
[Mon Oct 06 14:27:43.418201 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Mon Oct 06 14:27:43.418243 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] django.setup()
[Mon Oct 06 14:27:43.418254 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
[Mon Oct 06 14:27:43.418295 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] apps.populate(settings.INSTALLED_APPS)
[Mon Oct 06 14:27:43.418307 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
[Mon Oct 06 14:27:43.418444 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] app_config.import_models(all_models)
[Mon Oct 06 14:27:43.418457 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/django/apps/config.py", line 197, in import_models
[Mon Oct 06 14:27:43.418552 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] self.models_module = import_module(models_module_name)
[Mon Oct 06 14:27:43.418564 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Oct 06 14:27:43.418611 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] __import__(name)
[Mon Oct 06 14:27:43.418621 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/backgrounds-apps-server/movies_wallpaper/movies/models.py", line 6, in <module>
[Mon Oct 06 14:27:43.418682 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] from easy_thumbnails.fields import ThumbnailerImageField
[Mon Oct 06 14:27:43.418694 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/easy_thumbnails/fields.py", line 2, in <module>
[Mon Oct 06 14:27:43.418759 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] from easy_thumbnails import files
[Mon Oct 06 14:27:43.418783 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/easy_thumbnails/files.py", line 14, in <module>
[Mon Oct 06 14:27:43.419070 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] from easy_thumbnails import engine, exceptions, models, utils, signals, storage
[Mon Oct 06 14:27:43.419086 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] File "/var/www/XXX.net/api/lib/python3.4/site-packages/easy_thumbnails/engine.py", line 10, in <module>
[Mon Oct 06 14:27:43.419155 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] import Image
[Mon Oct 06 14:27:43.419176 2014] [:error] [pid 3050] [remote 188.121.29.164:61055] ImportError: No module named Image
Pillow is installed in virtual environment (pyvenv-3.4) and under idle python3.4 works fine.
Can someone tell me what is wrong with my configuration?
Best Answer
I figure it out by myself - I just installed wrong module. After
I installed libapache2-mod-wsgi-py3
it worked ;)