BogoToBogo
  • Home
  • About
  • Big Data
  • Machine Learning
  • AngularJS
  • Python
  • C++
  • go
  • DevOps
  • Kubernetes
  • Algorithms
  • More...
    • Qt 5
    • Linux
    • FFmpeg
    • Matlab
    • Django 1.8
    • Ruby On Rails
    • HTML5 & CSS

1. Django 1.8 Server Build - CentOS 7 hosted on VPS

django.png




Bookmark and Share





bogotobogo.com site search:




Note

This tutorial borrowed heavily from Django 1.7 Server Build - CentOS 7 hosted on VPS series. In general, the basic materials are still working fine. I used 'car'/'driver' instead of 'beer'/'drinker', and here and there, I had to modify or fill in stubs which were dropped in the videos. Other than the Django version 1.8, the rest of the environments were kept the same : Linode VPS / CentOS 7.

$ python
Python 2.7.5 (default, Jun 24 2015, 00:41:19)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django

>>> django.VERSION
(1, 8, 2, 'final', 0)
$ cat /etc/*release
CentOS Linux release 7.1.1503 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.1.1503 (Core)
CentOS Linux release 7.1.1503 (Core)

I have more tutorials than the original because I wanted each tutorial to be as short as possible.

In this and subsequent chapters, we'll make a Apache web server and set Django as a backend framework on CentOS 7 hosted on Linode.

One of the major factors choosing CentOS is the web hosting control panel compatibility. Within the web hosting industry, CentOS dominates, and most web hosting control panels, including cPanel, focus on RHEL derivatives like CentOS. So, I prefer CentOS to Ubuntu, but Ubuntu Server might be an excellent choice and can do everything that CentOS can. However, CentOS is the preferred distribution in the hosting industry, so if we want our server to be compatible with the majority of the industry, it's the safe choice.

In this chapter:

  1. We'll install CentOS 7 and boot up the machine.
  2. Then, we'll setup DNS for newly purchased domain name.




Linode Manager

LinodeManage.png

Click "Add this Linode!":

LinodeManagerStatus.png

Click "Dashboard":

LinodeDashboard.png

Next, select "Deploy an Image":

LinodeDeployImage.png

a

Hit "Deploy":

LinodeDeployed.png

Click "Boot" to boot the server:

LinodeDeployed.png

Now we did boot the server with a CentOS 7 image, and the server is running:

LinodeBooted.png






Remote access

Select "Remote Access" from the top menu:

RemoteAccess.png

We'll comeback to this later to setup ssh.





Setting Linode's Name Servers

See Setting Domain Names to Use Linode's Name Servers.

After we purchase a domain, the next step is setting our domain registrar to use our name servers. Use our domain name registrar's interface to set the name servers for our domain name to the following entries:

ns1.linode.com
ns2.linode.com
ns3.linode.com
ns4.linode.com
ns5.linode.com




Adding a new domain zone

Before we can add any DNS records, we must create a domain zone — a container for DNS records associated with a single domain name. The Linode Manager allows us to add new domain zones, import domain zones from other DNS servers, clone existing zones that we've already created in the DNS Manager, check to make sure that a zone is correctly loaded, view the raw output of a zone file, and permanently remove a zone and all associated DNS records.

If we have just purchased a new domain name, the first step is to add a new domain zone in the DNS Manager. This creates a container for the DNS records for our domain name. If we don't know what DNS records to add, the DNS Manager can insert some basic records when we create the new domain zone.

From the DNS Manager tab, select the Add a domain zone link.

AddDomainZone.png

Enter the domain name in the Domain field, and also enter an administer's email address in the SOA Email field.

AddDomainZone2.png

Click Add a Master Zone. Then, the following page appears, with our domain zone information:

LinodeDNS-Manager-SFVue.png



Checking

Under normal circumstances, there's no reason to suspect a problem with our domain zone or DNS records, but sometimes things go wrong. We can use the Check zone feature to verify that our domain zone is working correctly.

In order to check the status of our domain zone, from within the DNS Manager, click the Check option to the far right of our chosen domain zone.

LinodeCheck.png

A webpage with the results of the domain zone check will then appear.

LinodeCheckOK.png

If we see a message stating that our zone looks good, everything is working correctly; otherwise, check if all of the DNS records in our domain zone are properly configured.





Viewing

The DNS Manager allows us to view the contents of a domain zone file. This is especially useful should we need to import the zone to a different server, or if we wish to inspect the file.

We can view the contents of the domain zone file through the DNS Manager tab of our Linode Manager. From there, select the Zone file link to the far right column of our chosen domain's name.

ZoneFile.png

ZoneFileView.png



DNS Records

Once we've created a domain zone, we can start filling it with DNS records. DNS records are the link between our domain and our virtual private server. We'll see how to add, edit, and remove DNS records.

Should we remove our Linode(s), we will no longer be able to use Linode's DNS Manager to host our domain zones.





Adding DNS records
  1. Select a domain zone from within DNS Manager:

  2. SelectDomainZone.png

    SelectDomainZoneSFVue.png

  3. The page is divided into different sections for each type of DNS record. Locate the section for the type of DNS record we want to add, and then click the Add new [DNS] record link. But in our case, it looks it's been done already, and we do not have to do anything here.




Site - Domain Register

Since my domain sfvue.com is registered via other than Linode, we need to setup two things as shown below.

1. ip - pointing to Linode:

ZoneFilePointsTo.png

2. name servers - renamed to Linode's:

NameServerSettings.png





Waiting for Propagation

If we've just made a DNS change and aren't seeing it reflected yet, try waiting 48 hours. DNS updates will take effect, or propagate, within the time period set by our zone file's TTL. In some cases the new information may not be reflected for up to 48 hours.

While we can't control DNS caching at every point on the internet, we do have control over our web browser. Try holding down the Shift key or the Control key (depending on browser) while we refresh the page to bypass our browser's cache of the old DNS data. We can also try bringing up our site in an alternate browser, or Previewing Our Website Without DNS.





SSH Login and Firewall settings

Continued to 2. Django 1.8 Server Build - CentOS 7 hosted on Linode : ssh login and firewall














Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization

YouTubeMy YouTube channel

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







Django 1.8



Introduction - Install Django and Project Setup

Creating and Activating Models

Hello World A - urls & views

Hello World B - templates

Hello World C - url dispatcher

Hello World D - Models and SQLite Database

MVC - Hello World

Hello World on a Shared Host A

Hello World on a Shared Host B

Hello World - Admin Site Setup

virtualenv

Creating test project on virtualenv

Test project's settings.py

Creating Blog app and setting up models

Blog app - syncdb A

Blog app - syncdb B

Blog app - views and urls

Blog app - templates

Blog app - class based templates

Image upload sample code - local host

Authentication on Shared Host using FastCGI

User Registration on Shared Host A

User Registration with a Customized Form on Shared Host B

Blogs on Shared Host

Serving Django app with uWSGI and Nginx

Image upload sample code - shared host

Managing (Deploying) Static files (CSS, Images, Javascript) on Shared Host

Forum application on a Shared Host

Django Python Social Auth : Getting App ID (OAuth2) - Facebook, Twitter, and Google

Django: Python social auth, Facebook, Twitter, and Google Auth

Django: Python social auth, Facebook, Twitter, and Google Auth with Static files

...

Django 1.8 hosted on Linode VPS ==>

1. Setup CentOS 7 hosted on VPS

1B. Setup CentOS 7 hosted on VPS (multi-domain hosting setup) - Name server and Zone File settings (from GoDaddy to Linode)

2. ssh login and firewall

3. Apache Install

4. Install and Configure MariaDB Database server & PHP

5. Install and Configure Django

6. Model

7. Model 2 : populate tables, list_display, and search_fields

8. Model 3 (using shell)

9. Views (templates and css)

10. Views 2 (home page and more templates)

11. TinyMCE

12. TinyMCE 2

13. ImageField/FileField : Serving image/video files uploaded by a user

14. User Authentication 1 (register & forms)

15. User Authentication 2 (login / logout)

16. User Authentication 3 (password reset) - Sent from Email (gmail) setup etc.

17. User Authentication 4 (User profile & @login_required decorator)

18. User Authentication 5 (Facebook login)

19. User Authentication 6 (Google login)

20. User Authentication 7 (Twitter login)

21. User Authentication 8 (Facebook/Google/Twitter login buttons)

22. Facebook open graph API timeline fan page custom tab 1

23. Facebook Open Graph API Timeline Fan Page Custom Tab 2 (SSL certificate setup)

24. Facebook open graph API timeline fan page custom tab 3 (Django side - urls.py, settings.py, and views.py)

...

A sample production site Django 1.8.7: sfvue.com / einsteinish.com ==>

A sample production app (sfvue.com) with virtualenv and Apache

2. Upgrading to Django 1.8.7 sfvue.com site sample with virtualenv and Apache

(*) Django 1.8.7 einsteinish.com site - errors and fixes

Django 1.8.12 pytune.com site - local with Apache mod_wsgi

Django 1.8.12 pytune.com site - local with Nginx and uWSGI

Django 1.8.12 pytune.com site - deploy to AWS with Nginx and uWSGI

Django Haystack with Elasticsearch and Postgres

Django Compatibility Cheat Sheet

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong






Python tutorial



Python Home

Introduction

Running Python Programs (os, sys, import)

Modules and IDLE (Import, Reload, exec)

Object Types - Numbers, Strings, and None

Strings - Escape Sequence, Raw String, and Slicing

Strings - Methods

Formatting Strings - expressions and method calls

Files and os.path

Traversing directories recursively

Subprocess Module

Regular Expressions with Python

Regular Expressions Cheat Sheet

Object Types - Lists

Object Types - Dictionaries and Tuples

Functions def, *args, **kargs

Functions lambda

Built-in Functions

map, filter, and reduce

Decorators

List Comprehension

Sets (union/intersection) and itertools - Jaccard coefficient and shingling to check plagiarism

Hashing (Hash tables and hashlib)

Dictionary Comprehension with zip

The yield keyword

Generator Functions and Expressions

generator.send() method

Iterators

Classes and Instances (__init__, __call__, etc.)

if__name__ == '__main__'

argparse

Exceptions

@static method vs class method

Private attributes and private methods

bits, bytes, bitstring, and constBitStream

json.dump(s) and json.load(s)

Python Object Serialization - pickle and json

Python Object Serialization - yaml and json

Priority queue and heap queue data structure

Graph data structure

Dijkstra's shortest path algorithm

Prim's spanning tree algorithm

Closure

Functional programming in Python

Remote running a local file using ssh

SQLite 3 - A. Connecting to DB, create/drop table, and insert data into a table

SQLite 3 - B. Selecting, updating and deleting data

MongoDB with PyMongo I - Installing MongoDB ...

Python HTTP Web Services - urllib, httplib2

Web scraping with Selenium for checking domain availability

REST API : Http Requests for Humans with Flask

Blog app with Tornado

Multithreading ...

Python Network Programming I - Basic Server / Client : A Basics

Python Network Programming I - Basic Server / Client : B File Transfer

Python Network Programming II - Chat Server / Client

Python Network Programming III - Echo Server using socketserver network framework

Python Network Programming IV - Asynchronous Request Handling : ThreadingMixIn and ForkingMixIn

Python Coding Questions I

Python Coding Questions II

Python Coding Questions III

Python Coding Questions IV

Python Coding Questions V

Python Coding Questions VI

Python Coding Questions VII

Python Coding Questions VIII

Python Coding Questions IX

Python Coding Questions X

Image processing with Python image library Pillow

Python and C++ with SIP

PyDev with Eclipse

Matplotlib

Redis with Python

NumPy array basics A

NumPy Matrix and Linear Algebra

Pandas with NumPy and Matplotlib

Celluar Automata

Batch gradient descent algorithm

Longest Common Substring Algorithm

Python Unit Test - TDD using unittest.TestCase class

Simple tool - Google page ranking by keywords

Google App Hello World

Google App webapp2 and WSGI

Uploading Google App Hello World

Python 2 vs Python 3

virtualenv and virtualenvwrapper

Uploading a big file to AWS S3 using boto module

Scheduled stopping and starting an AWS instance

Cloudera CDH5 - Scheduled stopping and starting services

Removing Cloud Files - Rackspace API with curl and subprocess

Checking if a process is running/hanging and stop/run a scheduled task on Windows

Apache Spark 1.3 with PySpark (Spark Python API) Shell

Apache Spark 1.2 Streaming

bottle 0.12.7 - Fast and simple WSGI-micro framework for small web-applications ...

Flask app with Apache WSGI on Ubuntu14/CentOS7 ...

Selenium WebDriver

Fabric - streamlining the use of SSH for application deployment

Ansible Quick Preview - Setting up web servers with Nginx, configure enviroments, and deploy an App

Neural Networks with backpropagation for XOR using one hidden layer

NLP - NLTK (Natural Language Toolkit) ...

RabbitMQ(Message broker server) and Celery(Task queue) ...

OpenCV3 and Matplotlib ...

Simple tool - Concatenating slides using FFmpeg ...

iPython - Signal Processing with NumPy

iPython and Jupyter - Install Jupyter, iPython Notebook, drawing with Matplotlib, and publishing it to Github

iPython and Jupyter Notebook with Embedded D3.js

Downloading YouTube videos using youtube-dl embedded with Python

Machine Learning : scikit-learn ...

Django 1.6/1.8 Web Framework ...









Contact

BogoToBogo
contactus@bogotobogo.com

Follow Bogotobogo

About Us

contactus@bogotobogo.com

YouTubeMy YouTube channel
Pacific Ave, San Francisco, CA 94115

Pacific Ave, San Francisco, CA 94115

Copyright © 2024, bogotobogo
Design: Web Master