Monday, January 5, 2015

Re: Apache and Djagno



On Saturday, January 3, 2015 7:45:00 PM UTC+3, SungHo Park wrote:
Hi
I have tried to use Django in Apache, but it doesn't work.

My Django's version is 1.7.1 so I refered this page. https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ 

I'm Korean and not good at English. But I tried to read whole of the documents in that page, but it doesn't work.
I searched it in Korean language and found out that it needs to enter 'sudo a2ensite <project_name>', but it doesn't work, too.

I applied 
WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py  WSGIPythonPath /path/to/mysite.com    <Directory /path/to/mysite.com/mysite>  <Files wsgi.py>  Require all granted  </Files>  </Directory>
this. 
I use Ubuntu 14.04.









here is how i have done it,

install  mod_wsgi to assist the application communicate with apache
apt-get install libapache2-mod-wsgi

add this to you virtual host/ or apache default one /etc/apache2/sites-availavle/000-default.conf
WSGIScriptAlias / /path/to/yourDjagnoProject/yourDjagnoProject/wsgi.py
WSGIPythonPath /path/to/yourDjagnoProject
<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/yourDjagnoProject

       
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /path/to/yourDjagnoProject>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
   
# to load the static and media files e.g javascript and css
    # the /path/to/yourDjagnoProject/media and /path/to/yourDjagnoProject/static are folders
    #in you project tree, the first

    #the /media/ and /static/ are the name you in the actual code e.g in the template
    #  <link rel="stylesheet" href="{% static 'management/css/bootstrap.min.css' %}"/>
    Alias /media/ /path/to/yourDjagnoProject/media/
    Alias /static/ /path/to/yourDjagnoProject/static/


    <Directory /path/to/yourDjagnoProject/media>
        Require all granted
    </Directory>

    <Directory /path/to/yourDjagnoProject/static>
        Require all granted
    </Directory>
</VirtualHost>


thats all

--
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/1dd84850-6fca-4918-ae74-4c91063da6b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment