BitNami Django Stack

    BitNami Django Stack greatly simplify the development and deployment of Django applications. A BitNami stack is a preconfigured environment that is available as native installers, virtual machines and cloud images.

    How do I download and install Django Stack?

    djangostack.png You can download BitNami Django stack for your platform at http://bitnami.com/stack/django There are installers available for Windows, OS X and Linux operating systems.

    Currently there are available different versions of Django stack, depending on the Django version.

    BitNami Django Stack can also be deployed as virtual machines. If you are using the virtual machine, please see our Virtual Appliances documentation for instructions on logging into the machine.

    The Stacks can be also deployed as AMIs in the Amazon cloud. Please take a look at our Amazon Cloud Images quick guide to see how to connect to the instance from your machine.

    BitNami Django Stack is distributed free of charge under the Apache 2.0 license.

    Which components are installed with Django Stack?

    The BitNami Django Stack ships the components listed below. If you want to know which specific version of each component is bundled in the stack you are downloading, check the README.txt file in the download page or in the Stack installation directory. You can also find more information about each component using the links below.

    Main components:

    Dependencies and additional components:

    • SQLite database
    • Imaging
    • easy_install
    • pip
    • OpenSSL library
    • CURL library

    What is the default installation directory?

    When using native installers the default installation directory depends on the platform and can be changed during the installation:

    win_platform.png On Windows: C:\BitNami\djangostack-VERSION (On previous versions, the default installation directory was C:\Program Files\BitNami Django Stack)

    mac_platform.png On OS X: /Applications/djangostack-VERSION

    linux_platform.png On Linux: /home/user/djangostack-VERSION

    If you are using a virtual machine or the AMI, the default installation directory is "/opt/bitnami".

    How do I start and stop the servers?

    Each Django Stack ships several servers that must be started before you will be able to work with them. By default, MySQL or PostgreSQL database and Apache servers are started after the installation.

    Graphical tool

    The Stacks include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

    manager-osx.png

     

     

     

     

     

     

     

     

     


    win_platform.png

    On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> BitNami Stack -> Manager tool

    Command line tool

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

    $ cd ~/application-version
    $ ./ctlscript.sh start
    

    mac_platform.png

     

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start

    How can I run a command in the Django Stack?

    All of the Native Installers for BitNami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system. To work correctly, certain environment variables need to be set when you want to invoke commands to access different binaries. Note that in virtual machines or AMIs, the environment is already loaded for the "bitnami" user automatically and the below is not necessary.

    BitNami console is a script to load the Stack environment. This console is useful to run any command included in the Stack: python, pip, openssl, easy_install among others.

    linux_platform.png On Linux:

    $ cd ~/djangostack-version
    $ ./use_django
    
    

    win_platform.png On Windows:

    There is a shortcut in Start -> BitNami Ruby Stack ->"Use Django"

    mac_platform.png On OS X:

    Open a Terminal and type the following:

    hostname:~ user$ cd /Applications/djangostack-version
    hostname:~ user$ ./use_django
    

    How to start with the sample Django project?

    Once the installation or deployment finishes, you can access the welcome page from your browser. If you have installed the stack on a local machine as a regular user, you can access it at http://localhost on Windows or http://localhost:8080 on OS X and Linux. If not, you can specify the IP address of the server where you installed the Stack.

    You can access to the demo Project at "http://localhost/Project" on Windows or "http://localhost:8080/Project" on OS X or Linux. This sample project is running with "mod_wsgi"

    django-demo.png

     

    The Django project files are in the following location:

    "your_installdir/apps/django/django_projects"

    How to create a new Django project?

    To start a project with Django, it is necessary to start the BitNami Console. If you are using a Virtual Appliance or AMI, you can run the commands below directly.

    You should create your new project inside Django projects folder located at:

    linux_platform.png On Linux:

    installdir/apps/django/django_projects
    

    win_platform.png On Windows:

    For 2000, XP and 2003 Server:

    C:\Documents and Settings\user\Bitnami DjangoStack Projects
    

    For Vista, 7 and 2008 Server:

    C:\Users\user\Bitnami DjangoStack Projects
    

    mac_platform.png On OS X:

    /Applications/djangostack-version/apps/django/django_projects
    

    Run the following command to create a new project:                             

    $ django-admin.py startproject my_new_project
    

    If you wish to create a new applicaction inside the created project execute the following commands as well:

    $ cd my_new_project
    $ python manage.py startapp my_new_app
    

    How to start a Django project?

    There are two ways to start a Django project depending of if it is a development or a production environment.

    For development tasks you can use the standalone server in Django executing the following command inside your project's folder:

    $ python manage.py runserver ip:port
    

    ip and port are optional parameters. 127.0.0.1:8000 will be used by default if you don't specify any of them.

    Note that 127.0.0.1 is only accessible from the local machine. If you are remotely accessing the server you should use the ip 0.0.0.0 (or the server IP). Also make sure that the port is open in your firewall rules, for Bitnami Cloud hosting servers  check how to access your machine documentation.

    The other way is strongly recommended for production environments. It requires to configure Apache with mod_wsgi module before start serving your application. BitNami Stacks and Virtual Appliances for Django include mod_wsgi installed and activated by default. So you just need to create WSGI application script file and configure Apache to load it.

    First, create the WSGI application script file named 'projectName.wsgi' in 'installdir/apps/django/scripts' folder. Add the following content setting the correct the paths and project name:

    import os, sys
    sys.path.append('/path/to/your/django/projects/folder')
    sys.path.append('/path/to/your/project/folder')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'projectName.settings'
    
    import django.core.handlers.wsgi
    
    application = django.core.handlers.wsgi.WSGIHandler()
    

    Once created the WSGI file, create an Apache configuration file named 'projectName.conf' in 'installdir/apps/django/conf' to load it. Please, replace installdir with your installation directory (i.e. "/opt/bitnami") and pythonversion with the Python version (i.e. "python2.7" for Python version 2.7.x).

    Alias /static "installdir/apps/django/lib/pythonversion/site-packages/django/contrib/admin/static"
    
    <Directory 'installdir/apps/django/lib/pythonversion/site-packages/django/contrib/'>
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
    </Directory>
    
    WSGIScriptAlias /URL_mount_point "installdir/apps/django/scripts/projectName.wsgi"
    
    <Directory 'installdir/apps/django/scripts'>
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
    </Directory>
    

    Edit the file 'httpd.conf' and add the following line:

    Include "installdir/apps/django/conf/projectName.conf"
    

    Then restart the Apache server and visit your project at http://localhost:8080/projectName

    If you want to configure a database for your project, you can configure the "settings.py" file with the following settings. The examples below show how to configure the database connection with a database called "djangostack":

    • MySQL
     DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'djangostack',
            'HOST': '/opt/bitnami/mysql/tmp/mysql.sock',                                                 
            'PORT': '3306',
            'USER': 'your_user',
            'PASSWORD': 'your_password'
        }
    }
    • PostgreSQL
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'djangostack',
            'HOST': '/opt/bitnami/postgresql',
            'PORT': '5432',
            'USER': 'your_user',
            'PASSWORD': 'your_password'
        }
    }
    • SQLite
     DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': '/opt/bitnami/apps/django/django_projects/Project/Project/Project.db',
        }
    }
     

    The database connection is configured to use a socket. If you are using DjangoStack on Windows, you should use 'HOST': '127.0.0.1' .

    How to configure GeoDjango with PostGIS?

    This guide assumes that you are working with Django 1.5+ which already supports PostGIS 2.0+: GeoDjango with PostGIS quick start guide

    Tag page (Edit tags)
    • No tags
    Page statistics
    94566 view(s), 14 edit(s) and 7654 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments