Apache and Djagno

66 views
Skip to first unread message

SungHo Park

unread,
Jan 3, 2015, 11:45:00 AM1/3/15
to django...@googlegroups.com
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.









dsf

Mike Dewhirst

unread,
Jan 3, 2015, 5:50:48 PM1/3/15
to django...@googlegroups.com
Here is my working conf for Django 1.6.x, Apache2 and Ubuntu 14.04.

<IfModule mod_ssl.c>
<VirtualHost _default_:443>

SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite RC4-SHA:HIGH:!ADH
SSLCompression off
SSLCertificateFile /etc/ssl/certs/xxdxpq4.crt
SSLCertificateKeyFile /etc/ssl/private/xxdxpq4.key
SSLCACertificateFile /etc/ssl/certs/rapidssl-intermediate.crt
BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [7-9]" ssl-unclean-shutdown

DocumentRoot /var/www/xxdx/htdocs/
ServerName xxdx.pq4.com
ServerAdmin webm...@pq4.com

HostnameLookups Off
UseCanonicalName Off

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

Alias /robots.txt /var/www/static/xxdx/robots/robots.txt
Alias /favicon.ico /var/www/static/xxdx/img/xxdx.ico

# lock the public out
<Directory /var/www/xxdx/>
AllowOverride None
Order deny,allow
Deny from all
</Directory>

# serve uploaded media from here
<Directory /var/www/media/xxdx/>
AllowOverride None
Order deny,allow
Allow from all
</Directory>

# serve static stuff from here
<Directory /var/www/static/xxdx/>
AllowOverride None
Order deny,allow
Allow from all
</Directory>

<IfModule mod_alias.c>
Alias /media/ /var/www/media/xxdx/
Alias /static/ /var/www/static/xxdx/
Alias /tiny_mce/ /var/www/static/xxdx/js/tiny_mce/
Alias /jquery/ /var/www/static/xxdx/js/jquery/
</IfModule>

# now let the public access anything here
<Directory /var/www/xxdx/htdocs/>
AllowOverride None
Order deny,allow
Allow from all
</Directory>

<IfModule mod_wsgi.c>
WSGIScriptAlias / /var/www/xxdx/xxdx/wsgi.py
<Directory /var/www/xxdx/xxdx/>
Order deny,allow
Allow from all
</Directory>
</IfModule>

</VirtualHost>
</IfModule>

hth


>
>
>
>
>
>
>
>
>
> dsf
>
> --
> 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...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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/c88fc796-eed4-4eed-ba6a-11a6b7e3331e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c88fc796-eed4-4eed-ba6a-11a6b7e3331e%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Collin Anderson

unread,
Jan 4, 2015, 5:18:59 PM1/4/15
to django...@googlegroups.com
Hi,

What happens when you try?

"sudo a2ensite <projectname>" expects a file here: /etc/apache2/sites-available/<projectname>.conf

You then need to "sudo service apache2 reload"

Collin

Eddilbert Macharia

unread,
Jan 5, 2015, 9:08:17 AM1/5/15
to django...@googlegroups.com
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

th.gr...@free.fr

unread,
Jan 5, 2015, 5:49:38 PM1/5/15
to django...@googlegroups.com
hello
i have installed wsgi but i don't know how to use apache instead of the Django's runserver default
help!!!
Thanks

Eddilbert Macharia

unread,
Jan 6, 2015, 12:47:11 AM1/6/15
to django...@googlegroups.com
hello,

next set up n apaches virtual host as i have done above.

thats all.
Reply all
Reply to author
Forward
0 new messages