Sunday, January 26, 2014

Re: Problems Setting Up wsgi and Apache

Mark,

I'm doing this fine with Django 1.4.2 and Python 2.7.3.

My wsgi.py file looks like:


import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()



My Apache config looks like:



# WSGI setup, for use by Django and other Python webapps
# See notes in:
#  - http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
#  - http://code.google.com/p/modwsgi/wiki/ConfigurationIssues
#  - https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi
# --Fred 11/22/2012
WSGIPythonHome /var/python27/virtualenvs/hhl
<Directory "/var/www/wsgi-bin">
    Order allow,deny
    Allow from all
</Directory>
WSGIDaemonProcess wsgi_apps processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup  wsgi_apps
WSGIScriptAlias   /mypythonapp "/var/www/wsgi-bin/mypythonapp.wsgi"
WSGISocketPrefix  run/wsgi

#
# hhlweb Django app
#
<Directory "/var/www/django/hhlweb/apache">
    Order deny,allow
    Allow from all
</Directory>
WSGIDaemonProcess hhlweb processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup  hhlweb
# Note: Support both aliases for backward compatibility with release 1.
WSGIScriptAlias /hhlweb /var/www/django/hhlweb/apache/django.wsgi
WSGIScriptAlias /       /var/www/django/hhlweb/apache/django.wsgi

# Map the Django STATIC_URL to the Django STATIC_ROOT
<Directory /var/www/django/hhlweb/collected_static>
    Order deny,allow
    Allow from all
</Directory>
Alias /static/ /var/www/django/hhlweb/collected_static/

# Map the Django MEDIA_URL to the Django MEDIA_ROOT
<Directory /var/www/django/hhlweb/media>
    Order deny,allow
    Allow from all
</Directory>
Alias /media/ /var/www/django/hhlweb/media/



Hope this helps!
--Fred
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/26/14 5:15 PM, Mark Phillips wrote:
I have my first django app running using runserver. I am now trying to get Apache to serve my site. I have read the django docs and quite a few other references on the Internet, but I cannot get Apache to do anything with my django site. And no error message.

I am running django 1.6 in a virtual environment with Python 2.7 on Debian Linux inside my LAN. 

Configuration file for apache
/etc/apache2/sites-enabled/mom.conf:
<VirtualHost *:7000>
    ServerName beagle
    ServerAlias beagle
    ServerAdmin mark@beagle
    
    DocumentRoot /var/www/mom

    WSGIScriptAlias /mom /home/django/django_projects/inventory/inventory_project/wsgi.py

    <Directory /home/django/django_projects/inventory/inventory_project>
        Order deny,allow
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/mom/error.log
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/mom/access.log combined
</VirtualHost>

/home/django/django_projects/inventory/inventory_project/wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "inventory_project.settings.dev")

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

The project layout:
/home/django/django_projects/
└── inventory
    ├── fabfile2.py
    ├── fabfile.py
    ├── inventory
    │   ├── admin.py
    │   ├── admin.py~
    │   ├── admin.pyc
    │   ├── forms.py
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── migrations
    │   ├── models.py
    │   ├── models.py~
    │   ├── models.pyc
    │   ├── templates
    │   ├── templatetags
    │   ├── tests.py
    │   ├── urls.py
    │   ├── urls.py~
    │   ├── urls.pyc
    │   ├── views.py
    │   ├── views.py~
    │   └── views.pyc
    ├── inventory_project
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── media
    │   ├── settings
    │   ├── settings.py
    │   ├── settings.py~
    │   ├── settings.pyc
    │   ├── settings.py.old
    │   ├── static
    │   ├── urls.py
    │   ├── urls.py~
    │   ├── urls.pyc
    │   ├── wsgi.py
    │   └── wsgi.pyc
    ├── manage.py
    ├── mom
    ├── Notes.txt
    ├── README
    └── requirements.txt

/etc/apache2/mods-enabled/wsgi.conf
 WSGIPythonPath /home/django/django_projects/inventory:/home/django/.virtualenvs/inventory_project/lib/
python2.7/site-packages/

Any ideas on why I only get "Ooops cannot connect to beagle:7000/mom"?

Thanks,

Mark
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2O1ZfrsbywQWW9XSK5iEkybkMd4B%2B9Rxdi0bQC_Zzc%2BNA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment