Code Layout with an Apache Server

24 views
Skip to first unread message

Tom Browder

unread,
Mar 6, 2014, 5:24:41 PM3/6/14
to django...@googlegroups.com
I am working on my first Django project and would like to get comments
on a reasonable layout for a single Django instance used with several
Django projects where:

1. each project is a single web site on a unique virtual host (vhost)
2. all virtual hosts are on a single, real server running Debian 7
3. the real server is running a single Apache 2.4.7 (soon to be 2.4.8) instance
4. each virtual host using Django will be SSL/TLS only or non-SSL/TLS
(i.e., no mixed traffic ports at any one vhost)

Basically I would like to associate the project names with the virtual
host domain names, for example:

domain => project
============
domain1.com => domain1
domain2.com => domain2

I would also like to share common things between sites as much as possible.

Attached is a file showing the appropriate Apache httpd.conf section
illustrating my proposed vhost macro.

Note that the projects are all under:

/web-sites/${project}.${tld}/cgi-bin/${project}

so that that the Python base project name does not have a dot to
confuse Python treatment as a module.

Does anyone see any problems with this layout (except obvious lack of
common Python code treatment)?

I think it will be fairly easy to re-factor common code later.

Comments welcome.

Best regards,

-Tom
django-apache-layout.txt

Tom Browder

unread,
Mar 6, 2014, 7:29:22 PM3/6/14
to django...@googlegroups.com
On Thu, Mar 6, 2014 at 5:24 PM, Tom Browder <tom.b...@gmail.com> wrote:
> I am working on my first Django project and would like to get comments
> on a reasonable layout for a single Django instance used with several
...

In the attached file there were a couple of mistakes. In the macro
definition directive the file shows:

<Macro VHOST_NONSSL $project $tld>

and in the macro body a typical use is:

ServerName ${project}.${tld}

However the macro does not expand as I'm used to in shell and other
macro programming, so that

$project

is not the same as

${project}

so the macro definition directive should have been:

<Macro VHOST_NONSSL ${project} ${tld}>

Then the use of "${project}" and "${tld}" in the macro body is correct.

I have now successfully used such macros and they are a real boon for
using multiple virtual hosts.

Best regards,

-Tom

Tom Browder

unread,
Mar 6, 2014, 7:31:33 PM3/6/14
to django...@googlegroups.com
On Thu, Mar 6, 2014 at 7:29 PM, Tom Browder <tom.b...@gmail.com> wrote:
> On Thu, Mar 6, 2014 at 5:24 PM, Tom Browder <tom.b...@gmail.com> wrote:
>> I am working on my first Django project and would like to get comments
>> on a reasonable layout for a single Django instance used with several
> ...
>
> In the attached file there were a couple of mistakes. In the macro
> definition directive the file shows:
>
> <Macro VHOST_NONSSL $project $tld>

Note that mod_macro is a new feature in Apache 2.4--a good reason to
upgrade IMHO.

-Tom
Reply all
Reply to author
Forward
0 new messages