Hello Lee,

Do you ever expect to be running more than one Django site on your host?

In general, I try to keep as much as possible in its own directory- not in
OS standard places.  So I might have a structure like this:

/srv/website1
/srv/website2
...etc...

Under each "website" directory I have a complete Python virtualenv, as well
as the Django project.  All Python modules needed by the project are
included in the virtualenv, none of them are in the standard OS Python
modules directory.

I put the config files under
/etc/httpd/conf.d

... each file is read because the main httpd.conf includes this directory.

I do this to avoid issues during OS upgrades.  I also have the SELinux
contexts set properly so that Apache can read the directory.

-JK

---( Sent via Android )---
On Sep 12, 2014 4:05 PM, "lee" <[email protected]> wrote:

> Hello,
> I am deploying a new Django instance on a server running Apache and
> mod_wsgi - working off of a previous developers setup. I am new to this and
> while I got the new site up and running by copying what the previous person
> did, I am worried that he may not have things set up correctly. I have read
> through the mod_wsgi documentation and Django deployment pages but I would
> like to ask those with more expertise if my setup is safe and efficient.
>
> My Django project is running in var/www  - is this safe? My settings are
> in /etc/apache2/sites-available/default and my Django project settings are
> in a VirtualHost. Is this the correct place for these settings? I hope to
> eventually get the old instance of Django running on a suburl with the
> documentation here:
> http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html
>
> Thank you, Lee
>
> My project is located on /var/www/DjangoProject and static files have been
> collected to /var/www/DjangoProject/static
>
> /var/www/DjangoProject/wsgi.py
> import os
> import sys
> sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
> "../../")))
> sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
> "../")))
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DjangoProject.settings")
> from django.core.wsgi import get_wsgi_application
> application = get_wsgi_application()
>
>
>
> ---/etc/apache2/apache2.conf Other settings above this line
> WSGIPythonPath /var/www/DjangoProject/DjangoProject:/var/www/DjangoProject
> /env/lib/python2.6/site-packages
>
>
>
> --/etc/apache2/httpd.conf No other settings besides this line
> WSGIPythonPath /var/www/DjangoProject:/var/www/DjangoProject/DjangoProject
> :/var/www/DjangoProject/env/lib/python2.6/site-packages
>
>
> --/etc/apache2/sites-available/default
> NameVirtualHost *:8080
> <VirtualHost *:8080>
>         ServerAdmin webmaster@localhost
>         DocumentRoot /var/www
>         <Directory />
>                 Options FollowSymLinks
>                 AllowOverride None
>         </Directory>
>         <Directory /var/www/>
>                 Options Indexes FollowSymLinks MultiViews
>                 AllowOverride None
>                 Order allow,deny
>                 allow from all
>         </Directory>
>
>         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
>         <Directory "/usr/lib/cgi-bin">
>                 AllowOverride None
>                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
>                 Order allow,deny
>                 Allow from all
>         </Directory>
>
>         ErrorLog ${APACHE_LOG_DIR}/error.log
>         LogLevel warn
>         CustomLog ${APACHE_LOG_DIR}/access.log combined
> </VirtualHost>
>
> <VirtualHost *:80>
> ##############################
> ## DjangoProject WSGI         ##
> ##############################
>
> ServerName DjangoProject.mit.edu
> Alias /favicon.ico /var/www/DjangoProject/DjangoProject/static/favicon.ico
> AliasMatch ^/([^/]*\.css) /var/www/DjangoProject/MyApp/static/MyApp/css/$1
>
> Alias /media/  /var/www/DjangoProject/DjangoProject/media/
> Alias /static/ /var/www/DjangoProject/MyApp/static/
>
> <Directory /var/www/DjangoProject/MyApp/static>
> Order deny,allow
> Allow from all
> <IfModule mod_expires.c>
>   ExpiresActive On
>   ExpiresDefault "access plus 1 seconds"
>   ExpiresByType text/html "access plus 1 seconds"
>   ExpiresByType image/gif "access plus 10080 minutes"
>   ExpiresByType image/jpeg "access plus 10080 minutes"
>   ExpiresByType image/png "access plus 10080 minutes"
>   ExpiresByType text/css "access plus 60 minutes"
>   ExpiresByType text/javascript "access plus 60 minutes"
>   ExpiresByType application/x-javascript "access plus 60 minutes"
>   ExpiresByType text/xml "access plus 60 minutes"
> ExpiresByType text/xml "access plus 60 minutes"
> </IfModule>
> </Directory>
>
> <Directory /var/www/DjangoProject/DjangoProject/media>
> Order deny,allow
> Allow from all
> <IfModule mod_expires.c>
>   ExpiresActive On
>   ExpiresDefault "access plus 1 seconds"
>   ExpiresByType text/html "access plus 1 seconds"
>   ExpiresByType image/gif "access plus 10080 minutes"
>   ExpiresByType image/jpeg "access plus 10080 minutes"
>   ExpiresByType image/png "access plus 10080 minutes"
>   ExpiresByType text/css "access plus 60 minutes"
>   ExpiresByType text/javascript "access plus 60 minutes"
>   ExpiresByType application/x-javascript "access plus 60 minutes"
>   ExpiresByType text/xml "access plus 60 minutes"
> </IfModule>
> </Directory>
>
> WSGIDaemonProcess DjangoProject.example.com processes=2 threads=15
> display-name=%{GROUP}
>     WSGIProcessGroup DjangoProject.example.com
>
> WSGIScriptAlias /MyApp /var/www/DjangoProject/DjangoProject/wsgi.py
> WSGIScriptAlias / /var/www/DjangoProject/DjangoProject/wsgi.py
>
> <Directory /var/www/DjangoProject/DjangoProject>
> <Files wsgi.py>
> Order deny,allow
> Allow from all
> </Files>
> <IfModule mod_expires.c>
>   ExpiresActive On
> ExpiresDefault "access plus 1 seconds"
>   ExpiresByType text/html "access plus 1 seconds"
>   ExpiresByType image/gif "access plus 10080 minutes"
>   ExpiresByType image/jpeg "access plus 10080 minutes"
>   ExpiresByType image/png "access plus 10080 minutes"
>   ExpiresByType text/css "access plus 60 minutes"
>   ExpiresByType text/javascript "access plus 60 minutes"
>   ExpiresByType application/x-javascript "access plus 60 minutes"
>   ExpiresByType text/xml "access plus 60 minutes"
> </IfModule>
> </Directory>
>
> AddType audio/mpeg .mp1 .mp2 .mp3 .mpg .mpeg
> </VirtualHost>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/modwsgi.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to