apache - Deploying django project getting no result -


have googled quite bit , followed django documentation.. still won't work think i'm pretty close.. know there lots of information around tho i've tried few guides still won't work , think have tested stuff suggested in other topics..

i'm trying deploy django site @ server, working in development mode (from shell). when running python manage.py runserver it's fine, when trying apache2 server run django, first got "the requested url / not found on server.", in error.log of apache:

[client 192.168.1.49] mod_wsgi (pid=5606): exception occurred processing wsgi script '/home/webmod/www/djangojquerycontroller/server/server/wsgi.py'. [client 192.168.1.49] traceback (most recent call last): [client 192.168.1.49]   file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 236, in __call__ [client 192.168.1.49]     self.load_middleware() [client 192.168.1.49]   file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware [client 192.168.1.49]     middleware_path in settings.middleware_classes: [client 192.168.1.49]   file "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__ [client 192.168.1.49]     self._setup(name) [client 192.168.1.49]   file "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in _setup [client 192.168.1.49]     self._wrapped = settings(settings_module) [client 192.168.1.49]   file "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 134, in __init__ [client 192.168.1.49]     raise importerror("could not import settings '%s' (is on sys.path?): %s" % (self.settings_module, e)) [client 192.168.1.49] importerror: not import settings 'server.settings' (is on sys.path?): no module named server.settings 

so have installed things mentioned in https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/

well first of have site located at: /home/webmod/www/djangojquerycontroller/server

(the name of site server..) here's template, static , media folder along app datamanager doing of work. in folder /home/webmod/www/djangojquerycontroller/server/server find:

django.wsgi: (this file had manually create, don't know if worked alright..)

import os import sys  path = '/home/webmod/www/djangojquerycontroller/' if path not in sys.path:     sys.path.append(path)  os.environ.setdefault("django_settings_module", "server.settings")  import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler() 

wsgi.py: (from file can write error messages, file running (!))

import sys, os print  >>sys.stderr, "hej wsgi.py" sys.path.append('/home/wedmod/www/djangojquerycontroller/server') os.environ.setdefault("django_settings_module", "server.settings")  import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler( ) 

settings.py:

import warnings import exceptions # project_root = os.path.realpath(os.path.dirname(__file__)) warnings.filterwarnings("ignore", category=exceptions.runtimewarning,  module='django.db.backends.sqlite3', lineno=50)  debug = true template_debug = debug  databases = {     'default': {         'engine': 'django.db.backends.sqlite3',  # add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.         'name': '/home/webmod/www/djangojquerycontroller/server/server/db/database',  # or path database file if using sqlite3.         # following settings not used sqlite3:         'user': '',         'password': '',         'host': '',                      # empty localhost through domain sockets or '127.0.0.1' localhost through tcp.         'port': '',                      # set empty string default.     } }  allowed_hosts = []  time_zone = 'europe/stockholm'  language_code = 'en-us'  site_id = 1  use_i18n = true  use_l10n = true  use_tz = true  media_root = '/home/webmod/www/djangojquerycontroller/server/media'   media_url = 'media/'  file_upload_permissions = 755  static_root = '/home/webmod/www/djangojquerycontroller/server/static'    static_url = '/static/'  staticfiles_dirs = (     '/home/webmod/www/djangojquerycontroller/server/static/', )  staticfiles_finders = (     'django.contrib.staticfiles.finders.filesystemfinder',     'django.contrib.staticfiles.finders.appdirectoriesfinder',     'django.contrib.staticfiles.finders.filesystemfinder',     'django.contrib.staticfiles.finders.appdirectoriesfinder',     #'django.contrib.staticfiles.finders.defaultstoragefinder', )  admin_media_prefix = '/admin_media/'  # list of callables know how import templates various sources. template_loaders = (     'django.template.loaders.filesystem.loader',     'django.template.loaders.app_directories.loader',     #'django.template.loaders.eggs.loader', )  middleware_classes = (     'django.middleware.common.commonmiddleware',     'django.contrib.sessions.middleware.sessionmiddleware',     'django.middleware.csrf.csrfviewmiddleware',     'django.contrib.auth.middleware.authenticationmiddleware',     'django.contrib.messages.middleware.messagemiddleware', )  root_urlconf = 'server.urls'  # python dotted path wsgi application used django's runserver. wsgi_application = 'server.wsgi.application'  template_dirs = (     '/home/webmod/www/djangojquerycontroller/server/templates', )  installed_apps = (     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.sites',     'django.contrib.messages',     'django.contrib.staticfiles',     'datamanager',     'django.contrib.admin',     'django.contrib.admindocs',     'django_evolution', )  logging = {     'version': 1,     'disable_existing_loggers': false,     'filters': {         'require_debug_false': {             '()': 'django.utils.log.requiredebugfalse'         }     },     'handlers': {         'mail_admins': {             'level': 'error',             'filters': ['require_debug_false'],             'class': 'django.utils.log.adminemailhandler'         }     },     'loggers': {         'django.request': {             'handlers': ['mail_admins'],             'level': 'error',             'propagate': true,         },     } } 

then have tried 2 versions of https.conf in /etc/apache2:

alias /static/ /home/webmod/www/djangojquerycontroller/server/static/  <directory /home/webmod/www/djangojquerycontroller/server/static>     order deny,allow     allow </directory>  wsgiscriptalias / /home/webmod/www/djangojquerycontroller/server/server/django.wsgi  <directory /usr/local/django/mysite/apache>     order deny,allow     allow </directory> 

second test:

wsgiscriptalias / /home/webmod/www/djangojquerycontroller/server/server/wsgi.py wsgipythonpath /home/webmod/www/djangojquerycontroller:/usr/local/lib/python2.7/dist-packages/django <location "/server">     sethandler python-program     pythonhandler django.core.handlers.modpython     setenv django_settings_module server.settings     pythonoption django.root /server     pythonpath "['/home/webmod/www/djangojquerycontroller/',     '/home/webmod/www/djangojquerycontroller/server','/home/webmod/www/djangojquerycontroller/server/datamanager', '/home/webmod/www/djangojquerycontroller/'] + sys.path"     pythondebug on </location> 

/etc/apache2/sites-available/django.conf

<virtualhost *:80>  wsgiscriptalias / /home/webmod/www/djangojquerycontroller/server/server/wsgi.py  servername localhost  alias /media/ /home/webmod/www/djangojquerycontroller/server/static/ alias /static/ /home/webmod/www/djangojquerycontroller/server/static/  <directory /home/webmod/www/djangojquerycontroller/server/> order allow,deny allow </directory>  </virtualhost> 

so problem is, wrong this? why can't apache run thing it's supposed to.. if @ possible epic cool terminal commandos can copy paste , it's working magic! =)

any ideas solve nice!

you need add path of location settings.py file present , set environment variable settings. make following change wsgi files.

sys.path.append('/home/wedmod/www/djangojquerycontroller/server') os.environ["django_settings_module"]="settings" 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -