How To Deploy a Django App To apache2 Server On Ubuntu 20.04 LTS Desktop
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Django is a Python-based free and open-source web framework, which follows the model-template-view architectural pattern. It is maintained by the Django Software Foundation, an independent organization established as a 501 non-profit. Django's primary goal is to ease the creation of complex, database-driven websites.
Apache Web Server is designed to create web servers that have the ability to host one or more HTTP-based websites.
Offcial Website -https://www.djangoproject.com/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Our Server Specification:-
Os : Ubuntu 20.04 LTS (focal fossa) 64Bit | Hostname: www.yourdomain.com | IP Address of Server:192.168.1.50
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd ; getconf LONG_BIT ; hostname ; hostname -I && sudo apt install -y build-essential net-tools curl git software-properties-common apache2 libapache2-mod-wsgi-py3 python3-django
sudo a2enmod wsgi
sudo a2dissite 000-default ; sudo systemctl restart apache2 ; sudo systemctl reload apache2 ; sudo systemctl status apache2
sudo adduser oj
sudo usermod --lock oj ; sudo mkdir /home/oj/grouped
sudo chmod u=rwx,g=srwx,o=x /home/oj/grouped ; sudo chown -R oj.oj /home/oj/
sudo find /home/oj/grouped/ -type f -exec chmod -v ug=rw {} \; && sudo find /home/oj/grouped/ -type d -exec chmod -v u=rwx,g=srwx {} \;
sudo adduser $(whoami) oj ; newgrp oj
sudoedit /etc/apache2/sites-available/oj.conf
<VirtualHost *:80>
ServerName www.yourdomain.com
WSGIDaemonProcess oj user=oj group=oj threads=5 python-path="/home/oj/grouped/ojexamplecom/"
WSGIScriptAlias / /home/oj/grouped/ojexamplecom/ojexamplecom/wsgi.py
<Directory /home/oj/grouped/ojexamplecom/>
WSGIProcessGroup oj
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>
</VirtualHost>
sudo a2ensite oj
cd /home/oj/grouped/ ; django-admin startproject ojexamplecom
nano ojexamplecom/ojexamplecom/settings.py
'127.0.0.1', 'www.yourdomain.com'
sudo service apache2 restart
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks for information, but:
ReplyDeleteI did step by step,
Forbidden
You don't have permission to access this resource.