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

Cannot connect to PostgreSQL (listening on port 5432) in Bitnami Django (VM VirtualBox)

Edit the postgresql.conf (in the folder /opt/bitnami/postgresql/conf), by adding this line
#-------------------------------------------
# CONNECTONS AND AUTHENTICATION
#-------------------------------------------
listen_addresses = '*'

postgresql.conf
Restart the service,
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh restart postgresql
Check the remote connection again,
bitnami@debian:~$ pg_isready
postgresql_service

Ref:
Edit the postgresql.conf

git error: remote origin already exists

Sometime when we initialize the Local Repo, we get error: remote origin already exists.
The following step is solution.
Initialize the current folder as a Git repo:
bitnami@debian:~$ git init
bitnami@debian:~$ git remote add origin [email protected]:username/repostioryname.git
Then, error occurs:
error: remote origin already exists.
We need to remove the older origin by:
bitnami@debian:~$ git remote rm origin
Then, add the origin again:
bitnami@debian:~$ git remote add origin [email protected]:username/repostioryname.git
Add files:
bitnami@debian:~$ git add .
Commit with the descriptive message:
bitnami@debian:~$ git commit -m "Comment message"
Push the changes:
bitnami@debian:~$ git push -u origin master

Ref:
gitのエラー remote origin already existsの解決方法

Bitnami Django: Start or Stop Services (Apache, MariaDB, PostgreSQL)

Check the status of a service:
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh status
Start, Stop, Restart all services:
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh start
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh stop
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh restart
Restart a single service, such as Apache only, by passing the service name as argument:
bitnami@debian:~$ sudo /opt/bitnami/ctlscript.sh restart apache

Ref:
Start or Stop Services