![]() Install psycopg2 to help Django interact with PostgreSQL. In the settings.py file change the following: ALLOWED_HOSTS = Change DATABASES to this: DATABASES = Ħ. Test if the Django server is running, it will be at 127.0.0.01:8000 python manage.py makemigrations & python manage.py migrate python manage.py runserverĥ. Then create a Django project: python -m django startproject djangodemo_UIĤ. source djangodemo/bin/activate pip install django=2.2ģ. We’ll work on this as it’s the LTS version. Mkdir djangodemo cd djangodemo virtualenv -p python3 djangodemoĢ. Create a directory djangodemo and create a virtualenv using python3:.Setup Djangoįirst we’ll set up the virtual environment for Django so that it’s easily deployable on EC2. Finally, you exit out of the psql shell using \q. You also need to grant privileges to ‘ adesh’ user for ‘ djangodemodb’ database. Using these commands sequentially, you’ll create a database named ‘ djangodemodb’ and a new user ‘ adesh’ with ‘ mysercretpass’ as password. Now, let’s setup PostgreSQL, sudo su - postgres psql CREATE DATABASE djangodemodb CREATE USER adesh WITH PASSWORD ‘mysecretpass’ GRANT ALL PRIVILEGES ON DATABASE djangodemodb TO adesh \q exit Sudo apt-get update sudo apt-get install python-dev libpq-dev postgresql postgresql-contribĢ. In Security group, add rule with Type: HTTP, Port Range: 80, Source: Custom and 0.0.0.0/0, ::/0.Add Storage 20GB, it’ll be sufficient for now.Any instance type, we’ll choose t2.medium.Launch a new Instance on AWS EC2 using the following configs: Create Django apps, use PostgreSQL as a database and use Apache2 for handling multiple requests and some tips for logging and debugging errors. It’s fun to build apps as personal projects, but what if you want it to deploy it and showcase it to others? And not only that it should be able to handle multiple requests simultaneously.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |