Deploy A Django Project (Create a customer virtual host) for Production site

Deploy A Django Project

Approach A: Bitnami Installations Using System Packages
👆Identify whether the Bitnami stack uses native Linux system packages (Approach A),
or self-contained installation (Approach B) by running the command below:
bitnami@debian:~$ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

To serve the application through the Apache web server with the mod_wsgi module,
follow the steps below.
Enable WSGI configuration for the Django application
Ensure the Django project contains a wsgi.py file with contents similar to this:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PROJECT.settings')
application = get_wsgi_application()

wsgi.py
Enable predefined virtual hosts for a Django project
The Bitnami installation comes with predefined HTTP and HTTPS virtual hosts for running Django projects
with the mod_wsgi module. To enable them, follow the steps below:

  • Copy the files to remove the .disabled suffix:

NOTE: These files assume that the Django project is named sample
and is located at /opt/bitnami/projects/sample.
If your Django project is named or located differently, edit the
files below and update the file paths accordingly.
bitnami@debian:~$ sudo cp /opt/bitnami/apache2/conf/vhosts/sample-vhost.conf.disabled /opt/bitnami/apache2/conf/vhosts/sample-vhost.conf
bitnami@debian:~$ sudo cp /opt/bitnami/apache2/conf/vhosts/sample-https-vhost.conf.disabled /opt/bitnami/apache2/conf/vhosts/sample-https-vhost.conf

myapp-https-vhost.conf
myapp-http-vhost.conf

  • Restart Apache for the changes to be taken into effect:

bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh restart apache

Ref:
Connect To The Virtual Machine From Another Host

VMware Workstation Pro

VMware Workstation Player
VMware Workstation Player Documentation
VMware Workstation 16 Pro
Buy Online the License for VMware Workstation Pro –> Today Online bought! (199+13.93 = $212.93)
VMware Workstation (Compare Product)

Django Packaged By Bitnami For VMware Marketplace
How to share folders between Windows and Ubuntu using VMware Player
Manually Install VMware Tools on Linux
How to Install VMware Tools
Mounting VMware Shares from the Command Line on Linux VM
How to Install VMware Tools on Ubuntu/Debian VMware Virtual Machine
How to mount Windows shares in Mint Linux 18.3
Mounting Shared Folders in a Linux Guest

Mount VMware Shares on Linux VM:
bitnami@debian:~$ cd /opt/bitnami
bitnami@debian:/opt/bitnami$ sudo mkdir PROJECTS
bitnami@debian:/opt/bitnami$ sudo chmod 777 PROJECTS
bitnami@debian:/opt/bitnami$ cd
bitnami@debian:~$ sudo mount -t fuse.vmhgfs-fuse -o allow_other .host:/VM_DJPROJECTS /opt/bitnami/PROJECTS

If error happen, using this command,
bitnami@debian:~$ sudo vmhgfs-fuse -o nonempty -o allow_other .host:/VM_DJPROJECTS /opt/bitnami/PROJECTS

*VM_DJPROJECTS is the shared folder name in Host computer (Windows).
PROJECTS is the shared folder in Guest computer (Linux Debian).

Automatically Mount VMware Shares:
If you want the VMware Linux VM to automatically mount the VMware share on boot,
you have to add a new line to the /etc/fstab file.
bitnami@debian:~$ cd /etc
bitnami@debian:/etc$ sudo chmod 777 fstab
bitnami@debian:/etc$ emacs fstab

emacs_fstab
edit /etc/fstab file using emacs

Using chmod command to change file permission back to original.
bitnami@debian:/etc$ sudo chmod 644 fstab

fstab_file

Then, reboot.
bitnami@debian:/etc$ sudo reboot

How to add SSH Key to GitHub Account (application Bitnami Django)

Creat an SSH Key,
bitnami@debian:~$ ssh-keygen -t rsa -b 4096 -C "[email protected]"Substutute [email protected] with your email address.

・Press Enter to accept the default file location (/home/bitnami/.ssh/id_rsa).

・Enter the secure passphrase (password –> same as the GitHub account).

・Enter the command to display the contents of the generated public key,
bitnami@debian:~$ cat /home/bitnami/.ssh/id_rsa.pub
Add this public key to your GitHub Account.
Log into your GitHub Account.

・Click your avartar and choose settings.
BD_GitHub_SSH Key1

・Select SSH and GPG Keys
BD_GitHub_Add SSH Key_2

・Click New SSH Key button to create new SSH Key
BD_GitHub_SSH Key_3

・Enter the title in the Title filed and your public key from the above process in the Key field
BD_GitHub_SSH Key_4

Ref:
How to Add SSH Keys to Your GitHub Account

Now, you can process the commit your work.
bitnami@debian:~$ git status
bitnami@debian:~$ git add -A
bitnami@debian:~$ git commit -m "Any comment..."
bitnami@debian:~$ git push -u origin master

How to change Timezone in VirtualBox (Guest OS is Linux)

Ref: https://www.vpnttg.com/installation/virtualbox

List the Timezone
$ timedatectl list-timezones
Set the Timezone (e.g., Asia/Bangkok)
$ sudo timedatectl set-timezone Asia/Bangkok
Verify new setting by the following two commands,

  • date command: show date and current time
    $ date
  • ls -l /etc/localtime command: show Timezone info
    $ ls -l /ect/localtime

VMware vs. Virtual Box

VMware vs. Virtual Box: Comprehensive Comparison

Some conclusion:

  • If you need a free virtualization solution for a desktop, you can select VirtualBox.
  • If you need to have a free virtualization solution for running VMs on a server, select VirtualBox or VMware ESXi Free Edition.
  • If you need an ultimate solution for desktop with extended 3D graphics support and a wide list of settings, select VMware Workstation (or VMware Fusion for Mac computers).
  • If you need a free virtualization solution that only needs to run VMware VMs on desktop with basic options, you can select VMware Player.
  • If you need maximum integration between a VMware desktop solution and a VMware vSphere (vCenter server, ESXi hosts), select VMware Workstation or VMware Fusion Pro. You can use VMware Workstation or Fusion Pro for connecting to vCenter Server or ESXi host remotely, and can manage virtual machines residing on these resources. VMware provides a free VMware vCenter Converter for converting VMs of the Workstation format to VMs of the ESXi format (and vice versa).
  • If you have an old computer with a processor that does not support hardware virtualization technologies, select VirtualBox, which provides software virtualization.
  • If you need the ultimate enterprise-grade solution for deploying multiple servers, running a high number of VMs, using clustering features, etc., select VMware vSphere based on ESXi servers with vCenter.

More about virtualization solutions, compare VirtualBox with Hyper-V.