Skip to content

Cloud Blogs

Author – Madhusudhan Rao

Menu
  • AI for Healthcare
  • Archive Blogs
    • Cloud-Blogs by Madhusudhan Rao
      • ADF
        • ADF based Android Apps
        • ADF CRUD Cascaded LOVs
        • ADF CRUD Operation
        • ADF for Dummies
        • ADF for Financial Services Software Development
      • Analytics & Visualization
        • Business Intelligence
        • Oracle BI & DV Cloud Service
        • Setting up Oracle Analytics Cloud Instance and Data Visualization Techniques
      • App Servers & DevOps
        • How to deploy NodeJS Application on Oracle Application Container Cloud Service
        • Oracle Application Container Cloud Service
        • Oracle Java Cloud Service
      • OCI Admin Blogs
        • Create Oracle Cloud Infrastructure Instance
        • ElasticSearch & Kibana – Must for All Search Engine Development
        • How to Create Oracle Bare metal Compute Instance
        • Measuring Latency and TraceRoute Details with Oracle Edge Services
        • OCI Oracle cloud infrastructure – Setting up a NAT Instances for Public Internet Access from a Private Subnet
        • Oracle Cloud Infrastructure – OCI Creating buckets and object storage – setting up self expiry URLs
        • Oracle Cloud Infrastructure OCI – Create Instance ,Attach Block Volume , Open Ports, Setup Firewall rules
        • Python Basics
        • setting up Apache Tomcat on Oracle Cloud Infrastructure OCI
        • setting up CloudFlare DNS & HAProxy on Oracle Cloud Infrastructure for High Availability
        • Setting up Django Python Web Environment on Oracle Cloud
        • setting up File Storage on OCI and uploading files through Filezilla FTP
        • Setting up GPU-enabled Narupa server on Oracle Bare Metal Cloud for Virtual Reality Clients
        • setting up LAMP Stack , PHP 5.6, PhpMyAdmin , FTP and Mail Server on OCI
        • setting up Load Balancer on Oracle Cloud Infrastructure
        • setting up MongoDB Enterprise version Instance on Oracle Cloud Infrastructure Baremetal
        • setting up MongoDB on Oracle Cloud Infrastructure Classic and Opening Ports
        • Setting up SSH , FTP and Opening Ports on Oracle Cloud PaaS and IaaS
        • setting up web infrastructure DNS and HTTPS for your cloud Infrastructure as a Service OCI
        • World of Slack Programming
      • OCI Classic Blogs
        • How to Create WordPress blog on Oracle Cloud
        • running Function as a Service on Oracle Cloud Infrastructure – fnproject.io
        • running Hadoop & Big Data on Oracle Cloud Infrastructure
        • running TensorFlow Machine Learning for Image Recognition on Oracle Cloud Infrastructure
        • Setting up Kubernetes on Oracle Cloud Infrastructure – Classic
      • Oracle BPM for Financial Services
        • BPM for FS
        • 1. Setting up the development environment
        • 2. Modeling a home loan business process
        • 3. Implementing a home loan business process
        • 4. Deploying and testing a process workflow
        • 5. Administering processes
        • 6. Changing a business process by the process analyst
        • 7. Creating business reports for process owners
        • 8. Participating in a business process
        • 9. Integrating with business partners
        • 10. Collaborating with customers and end users
      • Oracle JET Series
    • Dockers on OCI Series
      • Comprehensive Blog on Dockers running on OCI
      • running a Docker Container on OCI
      • opening OCI Ports for Docker Containers
      • Building a Docker Image by using Dockerfile
      • Committing changes made in a Docker without using Dockerfile
      • pushing image to Docker Hub
      • DevOps with Github, Docker Hub and Oracle Container Cloud Services
      • running Apache Kafka for continuous data streaming on Oracle cloud infrastructure
    • Oracle Database Cloud Service
    • Oracle OKE Series
      • 01 Comprehensive Blog on Oracle Kubernetes Engine – getting started
      • 02 Configure Network Resources for Oracle Kubernetes Engine
      • 03 Creating 3 Worker and 2 Load Balancers Subnets for OKE
      • 04 Creating Oracle Kubernetes Cluster
      • 05 – Enable Cluster access through Command line interface
      • 06 – Getting onto Oracle Kubernetes Engine Dashboard
      • 07 Pod Configuration using a YAML Deployment
    • setting up and running Oracle Big Data PaaS
    • Setting up MySQL PaaS on Oracle Cloud
    • SOA BPM IDM Portal Series
      • FMW
        • Comprehensive Business Process Management – BPM 11g
        • FMW Install Startup Scripts
        • Oracle 11gR2 and 12c Database on Linux / OEL / Fedora
        • Oracle Identity Mangement
        • PS6, PS7, PS8 Install and Configuration
      • Webcenter Portal
        • Art of Webcenter Templating
        • Webcenter Sites Installation Linux
        • Webcenter Sites Look n feel
        • Webcenter Spaces
          • Custom Landing Page
        • Webcenter UCM Integration PS5
        • Webcenter, BPM Process Spaces – UCM PS5
        • BPM UCM and Webcenter PS5
      • BPM Series
        • 01-Simple BPM Task Initiator
        • 02-Business Rules and Exclusive Gateway
        • 03-Service Invocation Adapters
        • 04-BPM as a Web Service
        • 05-Mediator and Conditional Service Routing
        • 06-BPM Composer – Runtime Edit
        • 07-BPM and JMS Adapters
        • Oracle BPM 12c features
      • Process Cloud Service
        • Part 1 – Working with Process Cloud Service
        • Part 2 – How to Build Process , Data Persistence in Database Cloud Service
        • Part 3 – Invoking PCS Process from Oracle JET Framework
      • SOA Series
        • Oracle OSB 11g
        • Oracle SOA 11g Business Rules
        • Oracle SOA 11g DB Adapter
        • Oracle SOA 11g Mediator
        • SOA 11g AQ Adapters
    • Terraform on OCI Series
      • Create a Highly Scalable Cluster in the cloud using Terraform on OCI
      • Creating an Instance with New VNC Network
      • Managing the OCI Cluster with Slurm Workload Manager & Grafana
      • Terraform on OCI create instance
      • Terraform on OCI create load balancer
      • Terraform on OCI create non-federated user
      • Terraform on OCI create user, group, dynamic group and policies
      • Terraform on Oracle Cloud OCI
  • Database Series
    • Autonomous Data Warehouse and Analytics
      • 01 Preparing Client Machine
      • 02 Creating Autonomous Data Warehouse Instance
      • 03 Creating Tables into Autonomous Data Warehouse through SQL Developer
      • 04 Load Data into OCI Object storage and import that data into Autonomous Data warehouse
      • 05 Create Autonomous Analytics Cloud ADW Connection and create Data Visualization
    • Oracle Apex Cloud Service
Menu

Setting up Django Python Web Environment on Oracle Cloud

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Setting up a Django Python Environment on Oracle cloud can be little tricky as most documentations assume that the code is run on localhost, so thought let me put this on a blog article so it can help developers to easily run these environments on OCI

I would start with an assumption that an Ubuntu 18 Instance is already running on OCI , you need to ensure that port 8080 or 5000 is opened in Ingress Rule under Security List

No alt text provided for this image

the next thing of of many things 🙂 is to SSH into your Ubuntu environment and remove REJECT ALL firewall rule

 ubuntu@cblogs1:~$ sudo iptables --list --line-numbers Chain INPUT (policy ACCEPT) num  target     prot opt source               destination 1    ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED 2    ACCEPT     icmp --  anywhere             anywhere 3    ACCEPT     all  --  anywhere             anywhere 4    ACCEPT     udp  --  anywhere             anywhere             udp spt:ntp 5    ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh 6    REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num  target     prot opt source               destination 1    REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) num  target     prot opt source               destination 1    BareMetalInstanceServices  all  --  anywhere             link-local/16 Chain BareMetalInstanceServices (1 references) num  target     prot opt source               destination 1    ACCEPT     tcp  --  anywhere             169.254.0.2           owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images  section in the Oracle Bare Metal documentation for security  impact of modifying or removing this rule */ 2    ACCEPT     tcp  --  anywhere             169.254.2.0/24        owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images  section in the Oracle Bare Metal documentation for security impact of  modifying or removing this rule */ .... removing this rule */ reject-with icmp-port-unreachable ubuntu@cblogs1:~$ sudo iptables -D INPUT 6 ubuntu@cblogs1:~$ sudo netfilter-persistent save run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables save run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables save ubuntu@cblogs1:~$ sudo netfilter-persistent reload run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables start run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables start

Install Django Python Environment

(venv) ubuntu@aiml:~/mypython$ python -m django --version
/home/ubuntu/venv/bin/python: No module named django
(venv) ubuntu@aiml:~/mypython$ pip install Django
Collecting Django
Downloading https://files.pythonhosted.org/packages/39/
b0/2138c31bf13e17afc32277239da53e9dfcce27bac8cb68cf1c0123f1fdf5
/Django-2.2.3-py3-none-any.whl (7.5MB)
|████████████████████████████████| 7.5MB 24.5MB/s
Collecting sqlparse (from Django)
Downloading https://files.pythonhosted.org/packages/ef/53/
900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/
sqlparse-0.3.0-py2.py3-none-any.whl
Collecting pytz (from Django)
Downloading https://files.pythonhosted.org/packages/3d/73/
fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/
pytz-2019.1-py2.py3-none-any.whl (510kB)
|████████████████████████████████| 512kB 45.6MB/s
Installing collected packages: sqlparse, pytz, Django
Successfully installed Django-2.2.3 pytz-2019.1 sqlparse-0.3.0
(venv) ubuntu@aiml:~/mypython$ import django
Command 'import' not found, but can be installed with:
sudo apt install imagemagick-6.q16
sudo apt install graphicsmagick-imagemagick-compat
sudo apt install imagemagick-6.q16hdri
(venv) ubuntu@aiml:~/mypython$ python -m django --version
2.2.3

Check for Django Installation

(venv) ubuntu@aiml:~/mypython$ import django
Command 'import' not found, but can be installed with:
sudo apt install imagemagick-6.q16
sudo apt install graphicsmagick-imagemagick-compat
sudo apt install imagemagick-6.q16hdri
(venv) ubuntu@aiml:~/mypython$ python -m django --version
2.2.3
(venv) ubuntu@aiml:~/mypython$ django-admin startproject mysite
(venv) ubuntu@aiml:~/mypython$ ls
pycache main.py mysite web.py
(venv) ubuntu@aiml:~/mypython$ cd mysite/
(venv) ubuntu@aiml:~/mypython/mysite$ ls
manage.py mysite
ubuntu@aiml:~/mypython/mysite$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying auth.0001_initial… OK
Applying admin.0001_initial… OK
Applying admin.0002_logentry_remove_auto_add… OK
Applying admin.0003_logentry_add_action_flag_choices… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying sessions.0001_initial… OK

You would then need to edit settings.py where ALLOWED_HOSTS = [‘*’], so that access from Public Cloud is Enabled.

(venv) ubuntu@aiml:~/mypython/mysite$ cd mysite/
(venv) ubuntu@aiml:~/mypython/mysite/mysite$ cat settings.py
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 2.2.3.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
Build paths inside the project like this: os.path.join(BASE_DIR, …)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))
Quick-start development settings - unsuitable for production
See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '34u$l^ks4yl_#nj9uo&=&19y=gcv'
SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
ignore whatever below this …

the last thing of many things 🙂 is to run the Python Script at Server

(venv) ubuntu@aiml:~/mypython/mysite$ 
python manage.py runserver 0.0.0.0:8080
Watching for file changes with StatReloader
Performing system checks…
System check identified no issues (0 silenced).
July 21, 2019 - 16:34:10
Django version 2.2.3, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.
[21/Jul/2019 16:34:16] "GET / HTTP/1.1" 200 16348
[21/Jul/2019 16:34:16] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[21/Jul/2019 16:34:17] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
Not Found: /favicon.ico
[21/Jul/2019 16:34:17] "GET /favicon.ico HTTP/1.1" 404 1978
[21/Jul/2019 16:34:17] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184
[21/Jul/2019 16:34:18] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
Not Found: /tmUnblock.cgi
[21/Jul/2019 16:34:51] "POST /tmUnblock.cgi HTTP/1.1" 404 1974

This should allow us to access to our Python default Web App directly from Cloud VM Public Ip Address, now in your Browser open http:// < VM Public IP Address > : 8080 , you should be able to see Django Python Web application default page.

No alt text provided for this image

Please like the Blog if you really liked this 🙂

Regards, Madhusudhan Rao ( Cloud Architect @ Oracle )

reference :

https://www.linkedin.com/pulse/setting-up-django-python-web-environment-oracle-cloud-madhusudhan-rao/

https://docs.djangoproject.com/en/2.2/topics/install/#installing-official-release

https://www.djangoproject.com/

Log in
  • AI for Healthcare
  • Archive Blogs
    • Cloud-Blogs by Madhusudhan Rao
      • ADF
        • ADF based Android Apps
        • ADF CRUD Cascaded LOVs
        • ADF CRUD Operation
        • ADF for Dummies
        • ADF for Financial Services Software Development
      • Analytics & Visualization
        • Business Intelligence
        • Oracle BI & DV Cloud Service
        • Setting up Oracle Analytics Cloud Instance and Data Visualization Techniques
      • App Servers & DevOps
        • How to deploy NodeJS Application on Oracle Application Container Cloud Service
        • Oracle Application Container Cloud Service
        • Oracle Java Cloud Service
      • OCI Admin Blogs
        • Create Oracle Cloud Infrastructure Instance
        • ElasticSearch & Kibana - Must for All Search Engine Development
        • How to Create Oracle Bare metal Compute Instance
        • Measuring Latency and TraceRoute Details with Oracle Edge Services
        • OCI Oracle cloud infrastructure - Setting up a NAT Instances for Public Internet Access from a Private Subnet
        • Oracle Cloud Infrastructure - OCI Creating buckets and object storage - setting up self expiry URLs
        • Oracle Cloud Infrastructure OCI - Create Instance ,Attach Block Volume , Open Ports, Setup Firewall rules
        • Python Basics
        • setting up Apache Tomcat on Oracle Cloud Infrastructure OCI
        • setting up CloudFlare DNS & HAProxy on Oracle Cloud Infrastructure for High Availability
        • Setting up Django Python Web Environment on Oracle Cloud
        • setting up File Storage on OCI and uploading files through Filezilla FTP
        • Setting up GPU-enabled Narupa server on Oracle Bare Metal Cloud for Virtual Reality Clients
        • setting up LAMP Stack , PHP 5.6, PhpMyAdmin , FTP and Mail Server on OCI
        • setting up Load Balancer on Oracle Cloud Infrastructure
        • setting up MongoDB Enterprise version Instance on Oracle Cloud Infrastructure Baremetal
        • setting up MongoDB on Oracle Cloud Infrastructure Classic and Opening Ports
        • Setting up SSH , FTP and Opening Ports on Oracle Cloud PaaS and IaaS
        • setting up web infrastructure DNS and HTTPS for your cloud Infrastructure as a Service OCI
        • World of Slack Programming
      • OCI Classic Blogs
        • How to Create WordPress blog on Oracle Cloud
        • running Function as a Service on Oracle Cloud Infrastructure - fnproject.io
        • running Hadoop & Big Data on Oracle Cloud Infrastructure
        • running TensorFlow Machine Learning for Image Recognition on Oracle Cloud Infrastructure
        • Setting up Kubernetes on Oracle Cloud Infrastructure - Classic
      • Oracle BPM for Financial Services
        • BPM for FS
        • 1. Setting up the development environment
        • 2. Modeling a home loan business process
        • 3. Implementing a home loan business process
        • 4. Deploying and testing a process workflow
        • 5. Administering processes
        • 6. Changing a business process by the process analyst
        • 7. Creating business reports for process owners
        • 8. Participating in a business process
        • 9. Integrating with business partners
        • 10. Collaborating with customers and end users
      • Oracle JET Series
    • Dockers on OCI Series
      • Comprehensive Blog on Dockers running on OCI
      • running a Docker Container on OCI
      • opening OCI Ports for Docker Containers
      • Building a Docker Image by using Dockerfile
      • Committing changes made in a Docker without using Dockerfile
      • pushing image to Docker Hub
      • DevOps with Github, Docker Hub and Oracle Container Cloud Services
      • running Apache Kafka for continuous data streaming on Oracle cloud infrastructure
    • Oracle Database Cloud Service
    • Oracle OKE Series
      • 01 Comprehensive Blog on Oracle Kubernetes Engine - getting started
      • 02 Configure Network Resources for Oracle Kubernetes Engine
      • 03 Creating 3 Worker and 2 Load Balancers Subnets for OKE
      • 04 Creating Oracle Kubernetes Cluster
      • 05 - Enable Cluster access through Command line interface
      • 06 - Getting onto Oracle Kubernetes Engine Dashboard
      • 07 Pod Configuration using a YAML Deployment
    • setting up and running Oracle Big Data PaaS
    • Setting up MySQL PaaS on Oracle Cloud
    • SOA BPM IDM Portal Series
      • FMW
        • Comprehensive Business Process Management - BPM 11g
        • FMW Install Startup Scripts
        • Oracle 11gR2 and 12c Database on Linux / OEL / Fedora
        • Oracle Identity Mangement
        • PS6, PS7, PS8 Install and Configuration
      • Webcenter Portal
        • Art of Webcenter Templating
        • Webcenter Sites Installation Linux
        • Webcenter Sites Look n feel
        • Webcenter Spaces
          • Custom Landing Page
        • Webcenter UCM Integration PS5
        • Webcenter, BPM Process Spaces - UCM PS5
        • BPM UCM and Webcenter PS5
      • BPM Series
        • 01-Simple BPM Task Initiator
        • 02-Business Rules and Exclusive Gateway
        • 03-Service Invocation Adapters
        • 04-BPM as a Web Service
        • 05-Mediator and Conditional Service Routing
        • 06-BPM Composer - Runtime Edit
        • 07-BPM and JMS Adapters
        • Oracle BPM 12c features
      • Process Cloud Service
        • Part 1 - Working with Process Cloud Service
        • Part 2 – How to Build Process , Data Persistence in Database Cloud Service
        • Part 3 – Invoking PCS Process from Oracle JET Framework
      • SOA Series
        • Oracle OSB 11g
        • Oracle SOA 11g Business Rules
        • Oracle SOA 11g DB Adapter
        • Oracle SOA 11g Mediator
        • SOA 11g AQ Adapters
    • Terraform on OCI Series
      • Create a Highly Scalable Cluster in the cloud using Terraform on OCI
      • Creating an Instance with New VNC Network
      • Managing the OCI Cluster with Slurm Workload Manager & Grafana
      • Terraform on OCI create instance
      • Terraform on OCI create load balancer
      • Terraform on OCI create non-federated user
      • Terraform on OCI create user, group, dynamic group and policies
      • Terraform on Oracle Cloud OCI
  • Database Series
    • Autonomous Data Warehouse and Analytics
      • 01 Preparing Client Machine
      • 02 Creating Autonomous Data Warehouse Instance
      • 03 Creating Tables into Autonomous Data Warehouse through SQL Developer
      • 04 Load Data into OCI Object storage and import that data into Autonomous Data warehouse
      • 05 Create Autonomous Analytics Cloud ADW Connection and create Data Visualization
    • Oracle Apex Cloud Service

"Technology has the shelf life of a banana. By the time you buy it, implement it and train people on it, it’s obsolete. … ” as said by Mr Scott McNealy

© 2023 Cloud Blogs | Powered by Minimalist Blog WordPress Theme