How to properly configure a bunch of python 3.4 + django + apache 2.2 + virtualenv ?
Python 2.7 and python 3.2 are installed, python 3.4 is installed in the virtual environment. By 127.0.0.1:8000 site works.
How now to open access from the outside to the site?
Now I'm trying to run a clean django , i.e. test page. I do this: I launch Apache in a virtual environment, it runs without errors, writes only:
Could not reliably determine the server's fully qualified domain name using 127.0.1.1 for ServerName
I run the django runserver (uses python 3.4 ) - the django test page opens, and externally, error 500.
Apache config:
<VirtualHost *:80> ServerName myproject ServerAdmin mail@list.ru WSGIScriptAlias / /var/www/myproject/src/myproject/myproject/django.wsgi WSGIDaemonProcess myproject processes=1 maximum-requests=1 threads=1 WSGIProcessGroup myproject LogLevel debug ErrorLog /var/www/myproject/logs/myproject.error.log CustomLog /var/www/myproject/logs/myproject.access.log combined ServerSignature On <Directory "/var/www/myproject/src"> Order allow,deny Allow from all </Directory> </VirtualHost> Project structure:
/var/www/myproject ..../static_content ..../src ......../myproject ............manage.py ............/myproject ...............django.wsgi (использую сейчас) ...............settings.py ...............urls.py ...............wsgi.py (был изначально) .../logs .../env ......../bin .............activate .............activate.csh .............activate.fish .............django-admin .............django-admin.py .............easy_install .............easy_install-3.4 .............pip .............pip3 .............pip3.4 .............python -> python3.4 .............python3 -> python3.4 .............python3.4 -> /usr/local/opt/python-3.4.3/bin/python3.4 ......../include ......../lib ......../docs django.wsgi:
# -*- coding: utf-8 -*- import os, sys, site from django.core.wsgi import get_wsgi_application sys.path.insert(0, os.path.dirname(__file__)) site.addsitedir('/var/www/myproject/env/lib/python3.4/sitepackages') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler() wsgi.py (currently not used, it was originally, it didn’t work with it either):
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") application = get_wsgi_application() Apache logs write: [notice] Apache/2.2.22 (Debian) PHP/5.4.36-0+deb7u1 mod_wsgi/3.3 Python/3.2.3 configured -- resuming normal operations
In myproject.error.log:
[Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Create interpreter 'myproject|'. [Tue Jul 28 19:04:22 2015] [info] [client ::1] mod_wsgi (pid=3770, process='myproject', application='myproject|'): Loading WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi'. [Tue Jul 28 19:04:22 2015] [error] [client ::1] mod_wsgi (pid=3770): Target WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi' cannot be loaded as Python module. [Tue Jul 28 19:04:22 2015] [error] [client ::1] mod_wsgi (pid=3770): Exception occurred processing WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi'. [Tue Jul 28 19:04:22 2015] [error] [client ::1] Traceback (most recent call last): [Tue Jul 28 19:04:22 2015] [error] [client ::1] File "/var/www/myproject/src/myproject/myproject/django.wsgi", line 7, in <module> [Tue Jul 28 19:04:22 2015] [error] [client ::1] from django.core.wsgi import get_wsgi_application [Tue Jul 28 19:04:22 2015] [error] [client ::1] ImportError: No module named django.core.wsgi [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Maximum requests reached 'myproject'. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Shutdown requested 'myproject'. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Stopping process 'myproject'. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Destroying interpreters. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Destroy interpreter 'myproject|'. [Tue Jul 28 19:04:22 2015] [debug] mod_deflate.c(700): [client ::1] Zlib: Compressed 614 to 376 : URL / [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Cleanup interpreter ''. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Terminating Python. [Tue Jul 28 19:04:22 2015] [info] mod_wsgi (pid=3770): Python has shutdown. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Attach interpreter ''. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Create interpreter 'myproject|'. [Tue Jul 28 19:04:23 2015] [info] [client ::1] mod_wsgi (pid=3854, process='myproject', application='myproject|'): Loading WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi'. [Tue Jul 28 19:04:23 2015] [error] [client ::1] mod_wsgi (pid=3854): Target WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi' cannot be loaded as Python module. [Tue Jul 28 19:04:23 2015] [error] [client ::1] mod_wsgi (pid=3854): Exception occurred processing WSGI script '/var/www/myproject/src/myproject/myproject/django.wsgi'. [Tue Jul 28 19:04:23 2015] [error] [client ::1] Traceback (most recent call last): [Tue Jul 28 19:04:23 2015] [error] [client ::1] File "/var/www/myproject/src/myproject/myproject/django.wsgi", line 7, in <module> [Tue Jul 28 19:04:23 2015] [error] [client ::1] from django.core.wsgi import get_wsgi_application [Tue Jul 28 19:04:23 2015] [error] [client ::1] ImportError: No module named django.core.wsgi [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Maximum requests reached 'myproject'. [Tue Jul 28 19:04:23 2015] [debug] mod_deflate.c(700): [client ::1] Zlib: Compressed 614 to 376 : URL /favicon.ico [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Shutdown requested 'myproject'. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Stopping process 'myproject'. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Destroying interpreters. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Destroy interpreter 'myproject|'. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Cleanup interpreter ''. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Terminating Python. [Tue Jul 28 19:04:23 2015] [info] mod_wsgi (pid=3854): Python has shutdown. [Tue Jul 28 19:04:24 2015] [info] mod_wsgi (pid=3860): Attach interpreter ''.