Getting stuck on mod_wsgi

Vinnie James

Setting up an apache server on ubuntu for a django app. Getting stuck on the mod_wsgi configuration. Here is what is in the sites-available/000-default.conf currently:

WSGIPythonPath /var/www/html
WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py

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

    <Directory /var/www/html>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

Is something missing? The server wont return the default django admin page at :8080

André Teixeira

If you want things on port 8080, you must specify it on your config instead of the 80. What is on /var/www/html?? You should replace it with your Django project path, like /var/django/project_name/ or maybe /var/django/project_name/project_name (if you have it duplicated)

Here is how I've configured the wsgi.py successfully:

import os,sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('/var/django/project_name/project_name')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mideastinfo.settings'

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

On your VirtualHost directive on Apache config you must have:

WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py

Example:

<VirtualHost *:8080>
    ErrorLog /home/user/logs/error.log
    ...
    WSGIScriptAlias / /var/django/project_name/project_name/wsgi.py
    ...
</VirtualHost>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related