Setting up django and apache using the tutorial isn't working
Asked Answered
S

1

1

I am trying to set up apache with an existing django project using the tutorial in django site here. My os is Ubuntu, and everything is installed (django apache2 libapache2-mod-wsgi)

My conf file

WSGIPythonPath /home/avlahop/development/django/rhombus2/rhombus/

<VirtualHost *:80>
    ServerName myrhobmus.com
    ServerAlias www.myrhombus.com
    WSGIScriptAlias / /home/avlahop/development/django/rhombus2/rhombus/rhombus/wsgi.py 
</VirtualHost>

After I created the conf file I ran the a2ensite Ubuntu command for enabling the site.

Putting WSGIPythonPath inside VirtualHost gives me an apache configtest failure Files inside directive inside directory (as described in the example) gives me the same failure

If I go to www.myrhombus.com I get a Google chrome could not find the specified address message.

What am I doing wrong? Every tutorial on the Internet is using the old file.wsgi while now Django creates this for you but it is a python file with .py extension. How can I serve my django with apache? And If I wanted to go production at my own server where would you put django code and where would you put template files?

EDIT: I am only getting the Index of / page. Is there something I have to do with mysites location in terms of permissions? Could you give me a working example of an django site apache conf file?

Serotherapy answered 15/5, 2014 at 13:3 Comment(5)
What is the exact error you see?Marquisette
In which case?When restarting django or when trying to access my domain. I solved the domain access my putting record on by /etc/hosts like 127.0.0.1 www.myrhombus.com but now what I get is a list with the supposing files the directory is containing(but not showing any files) with the Index of / header and the name last modified Size description columnsSerotherapy
You said you got an Apache config test failure. What, exactly, did it say?Marquisette
If I add WSGIPythonPath inside VirtualHost the error I get is the following: Output of config test was: AH00526: Syntax error on line 5 of /etc/apache2/sites-enabled/rhombus.conf: WSGIPythonPath cannot occur within <VirtualHost> section Action 'configtest' failed. Files seems to be fixed. Maybe a typo of mine. But I just get the Index of / page instead of my django pageSerotherapy
@Serotherapy please , if you resolve and successfully deploy your project. hope some help .#33890777 i also face similar issue.Idiocy
I
0

I use Django 1.8 and I successfully deployed my project Apache server. I followed basic concept like you and enable Apache this module early.

enable module

You can my project structure this question.Refer this question to understand project structure

--------------this is my virtual host file----------------------------------

WSGIPythonPath /home/umayanga/Desktop/view_site/serialKey_gen_site:/home/umayanga/Desktop/view_site/serialKey_gen_site/myvenv/lib/python3.4/site$

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName key.com
    ServerAlias www.key.com

    Alias /templates/ /home/umayanga/Desktop/view_site/serialKey_gen_site/templates/
    Alias /static/ /home/umayanga/Desktop/view_site/serialKey_gen_site/static/


    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/static">
           Require all granted
    </Directory>

    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/templates">
           Require all granted
    </Directory>

    WSGIScriptAlias / /home/umayanga/Desktop/view_site/serialKey_gen_site/mysite/wsgi.py

    <Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/mysite">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
        <Files wsgi.py>
               Require all granted
        </Files>
    </Directory>

</VirtualHost>

-----------------wsgi.py---------------------------------------

"""
WSGI config for mysite project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application



os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

I think this will be help to you.

Idiocy answered 26/11, 2015 at 4:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.