You want to install Django and have it working for browsing from a desktop workstation. You do not want to leverage Django's API functionality. How do you install and configure Django from scratch?
pip3 is probably installed. If you are not sure, you could run this:
sudo find / -name pip3
You must have pip or pip3 installed. If you need assistance, see this posting.
- Run these two commands:
sudo yum -y install python3 mod_wsgi httpd sudo python3 -m pip install Django
- Find where the core subdirectory of Django is with this command:
sudo find / -name core -type d | grep django
- The parent directory, of the "core" directory found above, should have permissions configured such that the user who will start and stop Django services has the ability to write to it. Here is an example (but your path and method may vary):
sudo chown -R ec2-user:ec2-user /usr/local/lib/python3.6/site-packages/django/
- Run this command but change "contint" to the name your project:
django-admin startproject contint
- Find the external IP address of the server with this command:
- Back up the settings.py file that was created from the django-admin command. Find it (e.g., with
sudo find / -name settings.py | grep contint). After it is backed up, change the original.
- Edit the file (with the details in the step below). Here is an example of how to edit it:
- Find the ALLOWED_HOSTS stanza. Change it to look like this but replace "x.x.x.x" with the external IP address of the server:
ALLOWED_HOSTS = ['x.x.x.x']
Add or keep the single quotes inside the brackets. Save the changes and exit the file.
- Start the Django server (you may or many not need to change the path to the manage.py file):
python3 /usr/local/lib/python3.6/site-packages/django/contint/manage.py runserver 0.0.0.0:4466
- Draft this URL, but replace x.x.x.x with the external IP address of the server: http://x.x.x.x:4466
- Open a web browser and go to the URL.