On Jan 4, 3:11 pm, garagefan <***@gmail.com> wrote:
> this is rather aggravating as i'm unsure what exactly I need to give
> you to help me :/ this isn't your fault at all, as i'm an
> unexperienced with working with servers, mod_python, python and
> i am learning all this as I go along.
> i've got two websites on my server, both with different IP addresses
> they reside in
> the first directory above has another folder in it w/ my django files.
> full directory is /home/kdwadmin/mysite
> nevermind that my django files are placed in an inappropriate spot,
> i will be taking care of that shortly, /home/django/kdwadmin will
> contain the apps for the first site while there will be no directory
> for the second site at this time.
> my <Location>'s were set up as per the djangoprojects.com tutorial
> the first directory, that includes the django apps, is for website
> kennethdavid.net, the second for carclubhub.com.
> so what i need to do is set up a virtual host for both sites, one that
> will point kennethdavid.net/* to the django app and another that will
> say carclubhub.com/* SetHandler None
> there is only one port under "Listen" in the apache config file.
> Should i create an ip specific listen for each website? and have :80
> for one and :81 for the other and would that allow me to create two
> VirtualHosts? one for each port?
Sorry if I have come across as a bit short with you. Feeling a bit
under pressure at the moment with a report I have to do for work. I'll
try and explain things in a bit better detail for you. Hopefully it
will help with understanding Django documentation, which in my opinion
is not too clear in some areas in relation to mod_python setup. :-)
The whole point of virtual hosts as supported by the 'Host' header in
HTTP/1.1 requests, is that it is possible to support multiple named
hosts on a single IP address/port. Thus it is sufficient to have a
single Listen directive for just port 80. As you already had, you do
also need to define the NameVirtualHost directive appropriately to
enable virtual host resolution on that port. The wildcard, ie., '*'
means that this virtual host resolution will occur no matter what IP
address was used. So the directives:
would be fine.
The next thing is to define a VirtualHost container for each virtual
Since as explained above, the whole point of virtual hosts is support
more than one site on an IP at same port, you didn't actually need a
separate IP for each site. The only time you might really need
multiple IPs on same box for web hosting is if you wanted to use the
box to host a different site, but have it be hosted using a different
web server instance. For example, people often use nginx or lighttpd
to host static media files. If not on a different box and want
everything to appear at port 80, you need multiple IPs. Each web
server would then only listen on IP address for that server. That is
rather than '80', would listen on 'A.B.C.D:80'.
Anyway, ignoring multiple IPs and assuming only one, the VirtualHost
containers would then be:
That sets up the virtual hosts, but not Django itself.
For Django, since you want to mount Django at root of the virtual
host, ignoring issues of where Django code is located for now,
configuration would be:
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonPath "['/home/kwadmin', '/home/kwadmin/mysite] +
Note that no 'django.root' option is required for Django 1.0 if
mounted at '/'. That option is not relevant to older versions of
Note that both parent of Django directory and the Django directory are
listed to reduce chances of problems if you didn't list 'mysite' in
module references in urls.py or elsewhere.
The above assumes that the static file directories are under
These should be physical copies of the directory/files and not a
symlink if Apache not configured for allowing following of symlinks
under directory associated with DocumentRoot.
The other site would be similar:
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonPath "['/home/kwadmin2', '/home/kwadmin2/mysite] +
Only other thing to add is that because Apache runs as special user,
that user must be able to search directories and read files in those
directories. This applies to static files as well as code files making
up the Django site itself.
Guess the question now is how does that compare with what you have.
Secondly, with what should be correct configuration, what do you get
if you access:
Do you get a generic Apache HTTP error page with a simple test
message? If so, what does the message say?
Alternatively, does it appear that Django is triggered? That is,
returning a working Django page, or an error page?
If the correct content is returned, but styling is wrong and images
don't show, can you access style sheets and images using:
> On Jan 3, 10:21 pm, Graham Dumpleton <***@gmail.com>
> > On Jan 4, 1:39 pm, garagefan <***@gmail.com> wrote:
> > > there is currently only one virtual host set up, for the site i'm
> > > working on. I do not need anything to happen with the other url.
> > But why are you mentioning 'site2' in one of the other posts and
> > seeing for it what you only expect for 'site1'.
> > > i simply need a virtual host forwww.website.netthatsitsat /home/
> > > site1/ on my server that has a django directory at /home/site1/mysite
> > > to work.
> > Your initial configuration mentions /home/html in PythonPath. It is
> > very frustrating when people do not post exactly the Apache
> > configuration they are using and then try and describe in generic
> > terms using fake names and paths. It is okay if it is all consistent,
> > but your descriptions keep changing.
> > > the django files themselves at /mysite work just fine,
> > Can you clarify when you are talking about a URL or a directory. If a
> > directory, specify full path.
> > That you are mentioning '/mysite' here again is confusing because it
> > suggests a URL for a Django instance mounted at sub url of site, yet
> > you already seemed to have said you want to mount it at root of host,
> > ie., '/'.
> > > and
> > > were working before i attempted to set up the virtual host. and
> > >www.website.netwasworking just fine as well with the way the
> > > <Location *>'s are currently set up, before the virtual host stuff was
> > > added.
> > > i figure i'm missing something before the first <Location> that is
> > > causing the issue of the directory for the django apps not to be read.
> > > I do not want to set them up in the public_html directory as that is
> > > the main site directory, which if per chance i need to give someone
> > > access to that... i don't want them in the django directories at all.
> > It is unclear here whether you are talking about static files, eg.
> > images and stylesheets, or Django code. You should never stick Django
> > directory containing code inside of a Apache DocumentRoot directory
> > for a host. Your better choices are to copy the static file
> > directories into DocumentRoot or use a symlink to link them in from a
> > different location. Depending on Apache configuration you may need to
> > set FollowSymLinks option. Alternatively, use an Alias directive in
> > Apache to effectively mount them at required URL from some other
> > directory location. Either way, mod_python is a PITA in that you need
> > to have SetHandler None for the URL (Location) context where they are
> > when whole Django site is mounted at a parent URL to the static files.
> > > the server itself is a virtual server from godaddy running red hat 7
> > > w/ apache and mod_python.
> > > I was looking at a few pages and they mention DocumentRoot... should
> > > this be to /home/site1 or to the project files?
> > As I said above, you should never put Django code in DocumentRoot
> > because a mistake in Apache configuration can expose your source code
> > to download.
> > > how does PythonInterpreter need to be applied?
> > It doesn't if you are only hosting one Django site inside of a
> > VirtualHost.
> > Now, did you get rid of PythonOption to django.root which I said is
> > not needed if mounting Django at root of site. Be aware though that
> > that is an option only relevant to Django 1.0. Are you actually using
> > Django 1.0? If you are using older version of Django, then you aren't
> > reading the correct version of the documentation.
> > Problem now is that still not even clear what you actual problem is
> > any more. How about being very clear and give URLs for each request
> > you are making and state whether it works. Ie., does '/' work, does '/
> > images/...someimage.jpg' work, does some sub URL for part of your
> > application work? In other words, is the thing that doesn't work
> > static resources or dynamic resources? When you say you get nothing,
> > what do you mean by that, do you get a blank page, or simply not what
> > you expect?
> > If any don't work, is the error response a generic Apache error page
> > or a Django specific error page? Have you looked in the Apache error
> > logs to see if there are any Python error messages in there, or even
> > an indication that the Apache process has crashed with a segmentation
> > fault? Have you got DEBUG set to True for Django so that if Django is
> > generating the error that the error details are returned in the web
> > page?
> > Right now I can only guess at a few things. The first is django.root
> > as I mentioned, if you are indeed mounting Django at root of site. The
> > second is PythonPath doesn't also include Django instance directory in
> > addition to its parent. This latter will be an issue if in any part of
> > your code or urls.py file references stuff within the project without
> > explicitly referencing the site name.
> > To make any further guess you need to expand on the vague information
> > you have already provided as what constitutes don't work and what
> > exactly you were expecting to see.
> > BTW, it is presumed you properly restarted Apache between making
> > configuration changes.
> > Graham
> > > On Jan 3, 9:22 pm, Graham Dumpleton <***@gmail.com>
> > > wrote:
> > > > On Jan 4, 12:53 pm, garagefan <***@gmail.com> wrote:
> > > > > no, as then i would need to use, for example...www.website.net/mysite/*
> > > > > instead ofwww.website.net/*forthevariousapps.
> > > > If you are mounting it at root of web site, you should not be setting
> > > > django.root with PythonOption directive for a start. You only need set
> > > > django.root when mounted at a sub url. That you had set it gave the
> > > > impression you wanted it mounted at a sub url.
> > > > > as i said the locations worked perfectly before attempting to create
> > > > > the virtual host. right now i need to have this virtual host point to
> > > > > the correct website on my server.
> > > > As I said, you need to provide more complete configuration which shows
> > > > both Django sites and how you have set them up.
> > > > If your VirtualHost containers are the same except for ServerName in
> > > > each, then show that by providing the configurations for both, or be
> > > > clear about that and state it rather than us having to assume what it
> > > > all looks like.
> > > > > would i change server name to be an ip address? as each website on my
> > > > > server has a unique address, while having the same port? since 80 is
> > > > > the open port for apache
> > > > Show configurations for both VirtualHost's and then we may be able to
> > > > answer.
> > > > Graham
> > > > > On Jan 3, 8:47 pm, Graham Dumpleton <***@gmail.com>
> > > > > wrote:
> > > > > > On Jan 4, 12:17 pm, garagefan <***@gmail.com> wrote:
> > > > > > > I've read the documentation, and it doesn't seem clear enough, or
> > > > > > > provide a fully working example?
> > > > > > > i've copied what i have in my python.conf file, keep in mind that i
> > > > > > > have removed site specific names and have made them generic
> > > > > > > NameVirtualHost *:80
> > > > > > > <VirtualHost *:80>
> > > > > > > ServerNamewww.website.net
> > > > > > > <Location "/">
> > > > > > Presumably you mean /mysite here and not the root of the web server.
> > > > > > This needs to match what you have set django.root to.
> > > > > > Graham
> > > > > > > SetHandler python-program
> > > > > > > PythonHandler django.core.handlers.modpython
> > > > > > > SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> > > > > > > PythonOption django.root /mysite
> > > > > > > PythonDebug On
> > > > > > > PythonPath "['/home/html'] + sys.path"
> > > > > > > </Location>
> > > > > > > <Location "/styles">
> > > > > > > SetHandler None
> > > > > > > </Location>
> > > > > > > <Location "/images">
> > > > > > > SetHandler None
> > > > > > > </Location>
> > > > > > > </VirtualHost>
> > > > > > > i get no python errors, however when i go to the site i receive
> > > > > > > nothing. these locations worked previous to attempting to set up a
> > > > > > > virtual host. i assume *:80 is the port? in which case, i suppose it
> > > > > > > may be possible that the port is incorrect? in which case, i'm unsure
> > > > > > > as to where to check this... i assume under the apache conf file?
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to email@example.com
To unsubscribe from this group, send email to firstname.lastname@example.org
For more options, visit this group at http://groups.google.com/group/django-users?hl=en