|
List Info
Thread: Django hosting on WebFaction
|
|
| Django hosting on WebFaction |

|
2006-11-21 23:40:14 |
I am in the process of moving several sites from DreamHost
to
WebFaction (to get better performance and less flakiness),
but I've hit
a problem with the way Django is configured on WebFaction's
Shared 2
accounts.
I have the classic situation where I am trying to run a
development,
staging, and production version of a site, all using the
same database
and media files. Predictably, I'm using subversion to keep
them in
sync. I purchased a Shared 2 account which should be able to
host up to
5 Django sites. However, to do this you need to have all the
sites
running as different projects within the same Django
application. AFAIK
that means each project needs to have a different name.
(There's an
explanation of how to do this at
http:
//forum.webfaction.com/viewtopic.php?id=42)
However, because my 3 projects are essentially identical I
can't get
this to work. If I give them all different project names
things get
terribly screwed up. There are quite a few internal
references to the
project name, so I would have to maintain these references
separately
for each project - subversion can't manage this for me - and
the whole
methodology of dev/staging/prod breaks down.
Can anyone suggest a way of doing this sort of setup on
WebFaction?
Please don't tell me I have to move them back to DreamHost!
:-(
DH great for general hosting (I'll continue to serve my
media files
from there), but keeping Django sites running on DreamHost
is something
of a black art.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 01:25:37 |
|
I've been thinking about this since your first response, and I planned on trying it out for myself later on tonight. Since you're using the same name for each of your projects you can't place them in the same directory, what about subdirectories? For example:
~/webapps/<APPLICATION NAME>/env1/<PROJECT NAME> ~/webapps/<APPLICATION NAME>/env2/<PROJECT NAME> ~/webapps/<APPLICATION NAME>/env3/<PROJECT NAME>
And then in httpd.conf
you'd do something along the lines of:
<VirtualHost *:<PORT>> ServerName env1.example.com SetEnv DJANGO_SETTINGS_MODULE env1.project.settings # ...
</VirtualHost>
<VirtualHost *:<PORT>> ServerName env2.example.com SetEnv DJANGO_SETTINGS_MODULE env2.project.settings # ... </VirtualHost>
<VirtualHost *:<PORT>> ServerName env3.example.com SetEnv DJANGO_SETTINGS_MODULE env3.project.settings # ... </VirtualHost>
If that doesn't work then we will need more information, spending time taking shots in the dark isn't very amusing. :P I believe that sharing your database and media is trivial but you've mentioned it again, is there something that we're missing?
-David Sissitka On 11/21/06, Thomas Ashelford < ether.multimedia gmail.com">ether.multimedia gmail.com> wrote:
I am in the process of moving several sites from DreamHost to WebFaction (to get better performance and less flakiness), but I've hit a problem with the way Django is configured on WebFaction's Shared 2 accounts.
I have the classic situation where I am trying to run a development, staging, and production version of a site, all using the same database and media files. Predictably, I'm using subversion to keep them in
sync. I purchased a Shared 2 account which should be able to host up to 5 Django sites. However, to do this you need to have all the sites running as different projects within the same Django application. AFAIK that means each project needs to have a different name. (There's an
explanation of how to do this at http://forum.webfaction.com/viewtopic.php?id=42)
However, because my 3 projects are essentially identical I can't get
this to work. If I give them all different project names things get terribly screwed up. There are quite a few internal references to the project name, so I would have to maintain these references separately
for each project - subversion can't manage this for me - and the whole methodology of dev/staging/prod breaks down.
Can anyone suggest a way of doing this sort of setup on WebFaction?
Please don't tell me I have to move them back to DreamHost! :-(
DH great for general hosting (I'll continue to serve my media files from there), but keeping Django sites running on DreamHost is something of a black art.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Django hosting on WebFaction |

|
2006-11-22 03:01:32 |
Hi Thomas,
You shouldn't ever need to reference the project name, if
you set things up
properly. Go look at your python path setting in apache2,
that webfaction provides.
Initially it points to a project called myproject for the
settings file, so
you'll need to change this anyway. Go and change the
settings file for a
particular url tree to point to that project version. At the
same time, edit the
python path setting to point not only to the directory that
*contains* your
projects (you need this so you can still reference each
setting file uniquely, I
believe), but also points to the directory of your project
itself.
Then internally in your apps, etc, you only need to use
imports relative to your
project directly.
e.g.
import newsletter
instead of
import myproject.newsletter
If you set it up properly, apps can be ported easily from
project to project,
and all you need to fiddle with are templates, settings and
urls.
--
Lach
Personal: http://illuminosity.net/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 03:31:01 |
David - Thanks for taking the time to mull it over. Your
suggestion
looks promising, but as soon as I move my project into a
subdirectory I
get:
EnvironmentError: Could not import settings
'env1.<PROJECT
NAME>.settings' (Is it on sys.path? Does it have syntax
errors?): No
module named > env1.<PROJECT NAME>.settings
Maybe I need to tweak sys.path (this is pushing beyond the
limits of my
feeble understanding of Python), or maybe Django projects
just won't
work in subdirectories. Does anyone know for sure? Perhaps I
should
post a specific question about this to the Django developers
group.
I'm happy to post more info, but I wasn't sure what would be
useful.
And yes, sharing the database and media is trivial.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 04:04:07 |
Lachlan,
This makes sense. I'll give it a go. I've read up on setting
python
path, and that looks fairly straight forward. I still have a
lingering
doubt about importing 'newsletter' when I effectively have 3
versions
of 'newsletter' sitting on python path. How do I know it's
importing
the local one and not just the first one it finds?
Anyway, as I said I'll give it a go.
On Nov 22, 2:01 pm, Lachlan Cannon <l... illuminosity.net> wrote:
> Hi Thomas,
>
> You shouldn't ever need to reference the project name,
if you set things up
> properly. Go look at your python path setting in
apache2, that webfaction provides.
>
> Initially it points to a project called myproject for
the settings file, so
> you'll need to change this anyway. Go and change the
settings file for a
> particular url tree to point to that project version.
At the same time, edit the
> python path setting to point not only to the directory
that *contains* your
> projects (you need this so you can still reference each
setting file uniquely, I
> believe), but also points to the directory of your
project itself.
>
> Then internally in your apps, etc, you only need to use
imports relative to your
> project directly.
>
> e.g.
>
> import newsletter
> instead of
> import myproject.newsletter
>
> If you set it up properly, apps can be ported easily
from project to project,
> and all you need to fiddle with are templates, settings
and urls.
> --
> Lach
> Personal:http://illuminosity.net/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 04:13:14 |
The penny has just dropped - You mean I should specify a
different
python path for each site in the apache.conf, and that way
the imports
all work locally. Doh!
Thomas
> I still have a lingering
> doubt about importing 'newsletter' when I effectively
have 3 versions
> of 'newsletter' sitting on python path. How do I know
it's importing
> the local one and not just the first one it finds?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 05:00:22 |
|
I managed to get it working based on my idea, I'll post the httpd.conf on the WebFaction forums in a moment.
-David Sissitka
On 11/21/06, Thomas Ashelford
< ether.multimedia gmail.com">ether.multimedia gmail.com> wrote:
The penny has just dropped - You mean I should specify a different python path for each site in the apache.conf, and that way the imports all work locally. Doh!
Thomas
> I still have a lingering
> doubt about importing 'newsletter' when I effectively have 3 versions > of 'newsletter' sitting on python path. How do I know it's importing > the local one and not just the first one it finds?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Django hosting on WebFaction |

|
2006-11-22 06:40:22 |
Well, here's where I'm up to:
I followed Lachlan's idea, and successfully removed all the
internal
references to the project name. I got once such instance
working using
the following httpd.conf file:
ServerRoot
"/home2/fawebmin/webapps/django/apache2"
LoadModule python_module
/home2/fawebmin/webapps/django/apache2/modules/mod_python.so
LoadModule log_config_module
/home2/fawebmin/webapps/django/apache2/modules/mod_log_confi
g.so
LoadModule dir_module
/home2/fawebmin/webapps/django/apache2/modules/mod_dir.so
LoadModule mime_module
/home2/fawebmin/webapps/django/apache2/modules/mod_mime.so
LoadModule rewrite_module
/home2/fawebmin/webapps/django/apache2/modules/mod_rewrite.s
o
LoadModule env_module
/home2/fawebmin/webapps/django/apache2/modules/mod_env.so
Listen 2902
User fawebmin
Group fawebmin
LogFormat "%i %l %u %t
"%r" %>s %b "%i"
"%i"" combined
CustomLog
/home2/fawebmin/webapps/django/apache2/logs/access.log
combined
Errorlog
/home2/fawebmin/webapps/django/apache2/logs/error.log
DirectoryIndex index.py
ServerLimit 2
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE staging.settings
PythonPath "['/home2/fawebmin/webapps/django',
'/home2/fawebmin/webapps/django/staging'] + sys.path"
PythonDebug On
</Location>
Cool, this is going to work I thought...
But then I tried to install all 3 instances so they each
work at their
own subdomain. I already had a project at
webapps/django/staging, so I
added 2 more instances at webapps/django/development and
webapps/django/production. Then I followed the instructions
at
http:
//forum.webfaction.com/viewtopic.php?id=42 to arrive at
the
following httpd.conf file:
ServerRoot
"/home2/fawebmin/webapps/django/apache2"
LoadModule python_module
/home2/fawebmin/webapps/django/apache2/modules/mod_python.so
LoadModule log_config_module
/home2/fawebmin/webapps/django/apache2/modules/mod_log_confi
g.so
LoadModule dir_module
/home2/fawebmin/webapps/django/apache2/modules/mod_dir.so
LoadModule mime_module
/home2/fawebmin/webapps/django/apache2/modules/mod_mime.so
LoadModule rewrite_module
/home2/fawebmin/webapps/django/apache2/modules/mod_rewrite.s
o
LoadModule env_module
/home2/fawebmin/webapps/django/apache2/modules/mod_env.so
Listen 2902
NameVirtualHost *:2092
User fawebmin
Group fawebmin
LogFormat "%i %l %u %t
"%r" %>s %b "%i"
"%i"" combined
CustomLog
/home2/fawebmin/webapps/django/apache2/logs/access.log
combined
Errorlog
/home2/fawebmin/webapps/django/apache2/logs/error.log
DirectoryIndex index.py
ServerLimit 2
<VirtualHost *:2092>
ServerName fawebmin.webfactional.com
ServerAlias staging.fawebmin.webfactional.com
DocumentRoot /home2/fawebmin/webapps/django/staging
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE staging.settings
PythonPath "['/<home>/webapps/django',
'/home2/fawebmin/webapps/django/staging'] + sys.path"
PythonDebug On
</Location>
</VirtualHost>
<VirtualHost *:2092>
ServerName dev.fawebmin.webfactional.com
DocumentRoot /home2/fawebmin/webapps/django/development
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE development.settings
PythonPath "['/fawebmin/webapps/django',
'/home2/fawebmin/webapps/django/development'] +
sys.path"
PythonDebug On
</Location>
</VirtualHost>
<VirtualHost *:2092>
ServerName prod.fawebmin.webfactional.com
DocumentRoot /home2/fawebmin/webapps/django/production
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE production.settings
PythonPath "['/fawebmin/webapps/django',
'/home2/fawebmin/webapps/django/production'] +
sys.path"
PythonDebug On
</Location>
</VirtualHost>
I also used the control panel to create the neccesary
subdomains, and
pointed them to my Django application. Both the domain and
all 3
subdomains now return a 404 not found. Have I missed
something obvious
(or even something subtle)?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Django hosting on WebFaction |

|
2006-11-22 22:51:10 |
Thomas Ashelford wrote:
> The penny has just dropped - You mean I should specify
a different
> python path for each site in the apache.conf, and that
way the imports
> all work locally. Doh!
Yep
It's what I use for re-using apps between different client
sites -- I simply
have to drop them into the project directory, update urls,
settings and edit the
templates. Unfortunately, I've never done them in the same
hosting package,
using sub domains like you are. I'd like to at some point in
the future, though,
so if you get the conf file working, make sure you post it
to the list. Thanks!
--
Lach
Personal: http://illuminosity.net/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-9]
|
|