BitNami DjangoStack



Getting Started Resource Center / 10-Minute Tutorials / ..

BitNami DjangoStack for Mac. By BitNami Free. Developer's Description. By BitNami Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic. BitNami DjangoStack is a program that simplifies the deployment of Django and its runtime dependencies and includes ready-to-run versions of Python, Django, MySQL and Apache. It enables you to easily deploy a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Amazon Lightsail is the easiest way to get started on AWS. It offers virtual servers, storage, databases and networking, plus a cost-effective, monthly plan.

In this tutorial you deploy an example Django-based application onto Lightsail. You start by creating the instance, and deploying your application. Next, you ensure the application is running correctly using the Django’s built-in web server. Finally, you configure Apache to host the application.

Prerequisites

This is an intermediate level tutorial it assumes that you have:

  • A basic understanding of the Linux command line (cp, cat, etc.)
  • The ability to use a Linux text editor (vi, nano, etc)
  • At least a basic understanding of Django and Python
  • A free Amazon Web Services account
About this Tutorial
Time30 minutes
CostCosts may apply
Use CaseCompute
ProductsAmazon Lightsail
AudienceDeveloper
LevelIntermediate
Last UpdatedApril 13, 2021

a. Sign into your AWS account and navigate to the Lightsail home page.

f. You can leave the other settings at their default values. Scroll to the bottom of the screen and click Create Instance.

In this section you’re going to deploy a simple “Hello, World” application. You will use Django’s command line to create a new project as well as a new application before adding the actual application code in the next section.

If you already have a Django application written, feel free to use it for this tutorial. However, take note of the directory structure used in the “Hello, World” application, as it will be important when you configure your own application.

The Django project will be at the following directory

/opt/bitnami/projects

The project itself will be stored at the following directory

/opt/bitnami/projects/tutorial

The app will be created at the following directory

/opt/bitnami/projects/tutorial/hello_world

a. From the Lightsail home page click on the browser-based SSH client icon for your Django instance. This will start an SSH session into your instance. All the following commands should be run in that session.

b. Enter the following command to create the projects directory and give the current system user write permissions to the new directory.

BitNami

c. Enter the following command to change into the projects directory, and create a new tutorial project.

d. Enter the following command to change into the tutorial project directory, and create a new hello_world app.

Now that you have the scaffolding in place for your application, it’s time to add some code. The application will simply display “Hello, World” whenever the web page is loaded.

You should still be executing these commands in the Lightsail browser-based SSH client window.

a. Enter the following command to open the views.py file using the Vim text editor:

b. Type :1,$d and press Enter to select all, and delete the existing contents of the views.py file.

c. Press I to edit the file, and add the following code to the views.py file:

d. Press Esc, type :wq! , and press Enter to save and quit Vim.

e. Enter the following command to create a urls.py file for your application in the same directory as the views.py file:

Bitnami

f. Press I to edit the file, and add the following code:

g. Press the Esc, type :wq! , and press Enter to save and quit Vim.

h. Enter the following command to open the urls.py file:

i. Type :1,$d and press Enter to select all, and delete the existing contents of the urls.py file.

Bitnami Django Stack Tutorial

Press I to edit the file, and add the following code to the urls.py file:

i. Press the Esc, type :wq! , and press Enter to save and quit Vim.

Next, you’re going to use Django’s built-in web server to verify everything is working as expected. By default, Apache is using port 80 on your Lightsail instance, so you’ll run the Django web server on port 8000. To be able to access the website, you’ll need to open port 8000 on the Lightsail firewall.

a. Return to the Lightsail home page and click on the name of your Django instance.

e. Return to the Lightsail home page and make a note of the instance IP address.

f. Return to the terminal session, and enter the following command to open the settings.py file:

g. Press I and change the ALLOWED_HOSTS line to include the IP Address of your Need for speed run mac os torrent. Lightsail instance as shown in the following example.

Note: When editing your settings.py file, be sure to replace 192.0.2.143 with the public IP address of your instance.

h. Press the Esc, type :wq! , and press Enter to save and quit Vim.

Bitnami

i. Enter the following command to start Django’s web server on port 8000:

j. Point your web browser at port 8000 of the instances IP address (e.g. http:// 192.0.2.143:8000).

You should see “Hello, world”, which confirms that your application is running.

Press CTRL+C to stop the application.

It’s not recommended to run production applications using Django’s built-in server. So, in this final section you’ll configure Apache to serve your application.

You’ll do this by configuring the application to use Web Services Gateway Interface (WSGI), and then create an Apache virtual host (vHost).

You should still be executing these commands in the Lightsail browser-based SSH client window.

a. Type the following command to edit the wsgi.py file:

b. Type :1,$d and press Enter in Vim to select all, and delete the contents of the bitnami.conf file.

c. Press I to edit, and add the following code to the wsgi.py file:

d. Press the Esc, type :wq! , and press Enter to save and quit Vim.

e. Enter the following command to create a conf directory for your application

f. Enter the following command to create a httpd-app.conf file in the conf directory you just created:

h. Press the Esc, type :wq! , and press Enter to save and quit Vim.

i. Enter the following command to create a httpd-prefix.conf file in the conf directory for your application:

k. Press the Esc, type :wq!, and press Enter to save and quit Vim.

l. Enter the following command to open the bitnami.conf file:

m. Type :1,$d and press Enter in Vim to select all, and delete the contents of the bitnami.conf file

Bitnami Django Stack 9

n. Press I to edit, and add the following code to the file:

o. Press the Esc, type :wq!, and press Enter to save and quit Vim.

q. Point your web browser at the IP address of your instance (e.g. http:// 192.0.2.143).

You should see “Hello, world”, which confirms that your application is running.

Congratulations, you’ve completed the tutorial. You’ve successfully deployed a Django-based application on Lightsail.

Amazon Lightsail is a great choice to develop, build, and deploy a variety of applications like WordPress, websites, and blog platforms.

Was this tutorial helpful?

Please let us know what you liked.
Close
Is something out-of-date, confusing or inaccurate? Please help us improve this tutorial by providing feedback.
Close

Recommended next steps

Learn more

Add a static IP address

Upgrade Bitnami Stack

Assigning a static IP to your site ensures that the address does not change when the system is rebooted.

Create a DNS entry for your site

Bitnami Django Stack 8

Assign a DNS record to your site to make it easier for customers to access.

Bitnami Django Stacked

We are happy to report that BitNami Django Stack has been updated to include support for PostGIS and Python 2.7! While we already had this on our to-do list, feedback from several users inspired us to get it out the door earlier that planned. Thank you to everyone who took the time to let us know that they would like to see this, and please keep the feedback coming!
Note that currently, the built-in PostGIS integration is only for Linux and Mac OS X. You can manually install it on Windows (take a look at this). You may also want to check out our PostGIS Quick Start guide.