1

I have my development environment setup on Win 7 like this:

Django development structure

Apache      -server-        C:\Program Files (x86)\Apache Software Foundation\Apache2.4
PostgreSQL  -database-      C:\Program Files\PostgreSQL\9.2
Django      -framework-     C:\Python27\Lib\site-packages\django
Python      -code-          C:\Python27
Project     -root-          C:\mysite
    |----------apps
    |----------HTML
    |----------CSS
    |----------JavaScript
    |----------assets

I am attempting to keep this extremely simple to start out. There are 5 main directories each with a distinct purpose. All the code resides in the project folder.

compared to WAMP structure:

C:\WAMP
    |----------C:\Apache
    |----------C:\MySQL
    |----------C:\PHP
    |----------C:\www

I like how Apache, MySQL, and PHP all reside in a neat directory. I know to keep the root project OUTSIDE in another directory in Django for security reasons.

  • Is it fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?
  • Did I miss a core Django component and/or directory?
  • Will deploying and scaling be a problem?

I want this to be a guideline for beginning Django web programmers.

Snerd
  • 1,463
  • 3
  • 25
  • 36

3 Answers3

1

Apache is just web server, it is used to serve files, but to make a website you do not necessary need it. Django comes with its own development server. See :

python manage.py runserver

Apache is required when you are developing PHP websites because your computer do not know how to compile and interpret it. But for Django, you use the Python language, and you have already install it if you are using Django.

Read https://docs.djangoproject.com/en/1.5/intro/tutorial01/

And where it will be the time to set up your own server using Apache look at : https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/.

Gabriel Pichot
  • 2,325
  • 1
  • 22
  • 24
  • I have been using "python manage.py runserver". When time comes to deploy = use apache. – Snerd Jul 16 '13 at 22:54
1

I can answer the question one by one:

  • Is if fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?

    All over the place sounds weird but yes it is totally fine.

  • Did I miss a core Django component and/or directory?

    No you don't miss anything, Django core is in site-packages folder already and your site code is mysite, which can be located anywhere you want.

  • Will deploying and scaling be a problem?

    No it won't be a problem with current structure. You will deploy your mysite only, the other will be installed separately.

Something you should get familiar with when starting with Django development:

  • Most likely when you deploy your project, it will be on a Linux server, so install and learn Linux maybe?

  • virtualenv: Soon you will have to install Django, then a bunch of external packages to support your project. virtualenv helps you isolate your working environment. Well it's "unofficial" a must when you start with python development.

  • virtualenvwrapper to make your life easier when working with virtualenv

  • git and github or bitbucket: if you don't know git yet, you should now.

Community
  • 1
  • 1
Hieu Nguyen
  • 8,563
  • 2
  • 36
  • 43
  • "All of the place" is actually pretty much apache and postgresql being installed "further away inside program files directories. For deploying = mysite only sounds good. – Snerd Jul 16 '13 at 22:51
  • I have tested out virtualenv (it works) but not virtualenvwrapper yet. – Snerd Jul 16 '13 at 22:55
  • 1
    Yes I know what you meant. Good it seems you are all set for the real development ;) – Hieu Nguyen Jul 16 '13 at 22:57
  • Thanks for the advise. I wanted everything to be simple and organized with growth in mind. – Snerd Jul 16 '13 at 23:00
1

Scaling will be a problem on windows. Python in Apache on windows gets 64 threads in one process. Couple this with the GIL and you will have scaling issues.

Python and Apache on Linux don't have this same problem. Under Linux wsgi can create multiple processes that have multiple threads each, minimizing GIL issues.

WSGI in Apache on windows is not a scalable solution in my opinion.

However you can develop there and move to linux for deployment, I do it all the time.

You will want to take advantage of the Apache Alias directive to serve all your static content like css, js, favicon.ico. This frees up python to only handle requests that require logic.

boatcoder
  • 17,525
  • 18
  • 114
  • 178
  • "However you can develop there and move to linux for deployment, I do it all the time." Exactly my plan. – Snerd Jul 26 '13 at 00:22
  • http://webpy.org/cookbook/staticfiles is this what you meant by using the Apache alias directive? – Snerd Jul 26 '13 at 00:22
  • 1
    Yes, that is what I meant by the apache alias directive. I updated the answer to include the link to the offical apache docs too. – boatcoder Jul 26 '13 at 14:22