{"id":23291552,"url":"https://github.com/guycole/django-lab","last_synced_at":"2026-05-09T04:32:10.644Z","repository":{"id":141768933,"uuid":"146084416","full_name":"guycole/django-lab","owner":"guycole","description":"Django Experiments","archived":false,"fork":false,"pushed_at":"2018-09-02T07:24:56.000Z","size":2183,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T17:52:15.048Z","etag":null,"topics":["aws-ec2","django-application","postgresql","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guycole.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-25T09:55:54.000Z","updated_at":"2020-01-05T18:13:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7a3ddf4-abad-43a5-b3ca-6ce8fd96dba8","html_url":"https://github.com/guycole/django-lab","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/guycole/django-lab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guycole%2Fdjango-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guycole%2Fdjango-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guycole%2Fdjango-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guycole%2Fdjango-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guycole","download_url":"https://codeload.github.com/guycole/django-lab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guycole%2Fdjango-lab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32807185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-ec2","django-application","postgresql","python3"],"created_at":"2024-12-20T05:18:26.868Z","updated_at":"2026-05-09T04:32:10.625Z","avatar_url":"https://github.com/guycole.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-lab\nA simple demonstration of a Django/PostGreSQL/EC2 deloyment.  Run time \neconomy is the primary goal.  Most examples focus on a dejango deployment\nvia Elastic Beanstalk and connected to RDS, nice but managed \nservices are pricey.  Many applications run well enough w/the database \nand web server on the same EC2 instance.  This project demonstrates a \nminimal deployment to AWS LINUX hosted on a single EC2 server.  \n\nThis is not a beginners tutorial.  Not so advanced either, but assumes \nyou know AWS EC2, UNIX and django. \n\nThe django project is named \"mvp\" and consists of two simple applications \n(\"app1\" and \"app2\") because I wanted to investigate navigating between \nmultiple applications.\n\nI created an account \"django\" to hold the django application.  httpd \n(apache) will use uwsgi as a bridge to django.  \"django\" (the UNIX account) \nwill need to be a member of the apache (UNIX) group.\n\n## EC2 (deployment environment)\n\n1.  Start an EC2 instance.  Original MVP development was on a t2.small \ninstance using a LINUX2 AMI w/a 8GB EBS file system.\n\n1.  Install these packages (as root)\n    1. `yum -y groupinstall 'Development Tools'`\n    1. `yum -y install python3 python3-devel httpd-devel`\n    1. `yum -y install postgresql postgresql-server`\n\n1.  Configure PostGreSQL\n    1. `service postgresql initdb` (as root)\n    1. edit /var/lib/pgsql/data/postgresql.conf\n        1. enable a listener on localhost by uncommenting\n            1. listen_addresses = 'localhost'\n            1. port = 5432\n    1. edit /var/lib/pgsql/data/pg_hba.conf\n        1. trust users on the loopback\n            1. local   all             all                                     trust\n            1. host    all             all             127.0.0.1/32            trust\n            1. host    all             all             ::1/128                 trust\n    1. start postgresql \n        1.  `service postgresql start` (as root)\n    1.  Verify postgres is working by logging in\n        1. `psql -d template1 -U postgres`\n        1. `\\q` will exit\n\n1.  Start httpd and ensure you can connect to it\n    1. `service httpd start` (as root)\n    1. visit your public IP address w/a browser, should see Apache test page\n\n1.  Install virtualenv (as root)\n    1. `pip3 install virtualenv`\n\n1.  Create a LINUX user account 'django' to hold the project, and add to apache group\n    1. `useradd -m django` (as root)\n    1. `usermod -a -G apache django` (as root)\n    1. `chown -R django:apache /var/www` (as root)\n    1. `sudo chmod 2775 /var/www` (as root)\n\n1.  su to django \n    1. pull sources from github\n        1. `git clone https://github.com/guycole/django-lab.git`\n    1. create postgresql user and database\n        1. run postgres/genesis.sh (genesis.sql contains postgresql operations)\n    1. verify happy postgres account and database creation\n        1. `psql -U django -d mvp` (there are no tables yet)\n        1. `\\q` will exit\n    1. establish virtualenv and seed environment\n        1. `cd` (return to home directory)\n        1. `virtualenv -p /usr/bin/python3 venv`\n        1. `source venv/bin/activate`\n        1. `pip install -r requirements.txt`\n        1. Check for happy django startup\n            1. `python manage.py runserver` (Control C to exit)\n        1. Run migrations and ensure ok database connection\n            1. `python manage.py migrate`\n        1. Collect static images (i.e. files)\n            1. `python manage.py collectstatic`\n        1. Edit mvp/settings.py and tweak ALLOWED_HOSTS to reflect your EC2 public IP\n    1. build and install mod_wsgi\n        1. latest sources are at https://github.com/GrahamDumpleton/mod_wsgi/releases\n        1. `cd` (return to home directory)\n        1. `curl https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.6.4 --output mod_wsgi.tgz`\n        1. `tar -xvzf mod_wsgi.tgz; cd mod_wsgi-4.6.4; ./configure; make`\n        1. exit (back to UNIX root shell), `cd /home/django/mod_wsgi-4.6.4; make install`\n\n1.  configure httpd\n    1.  edit /etc/httpd/conf/httpd.conf (as root)\n```\nWSGIScriptAlias / /home/django/django-lab/mvp/mvp/wsgi.py\nWSGIPythonHome /home/django/venv\nWSGIPythonPath /home/django/django-lab/mvp\n\n\u003cDirectory /home/django/django-lab/mvp\u003e\n  \u003cFiles wsgi.py\u003e\n    Require all granted\n  \u003c/Files\u003e\n\u003c/Directory\u003e\n\nAlias /static/ /home/django/django-lab/mvp/static/\n\u003cDirectory /home/django/django-lab/mvp/static\u003e\n  Require all granted\n\u003c/Directory\u003e\n\nLoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so\n```\n    1. ensure file permissions are ok\n        1. `chmod 750 /home/django`\n        1. `chgrp -R apache /home/django`\n    1. restart httpd\n        1. `service httpd restart`\n        1. ensure mod_wsgi is loaded\n            1. `httpd -M | grep -i wsgi`\n    \n1. Visit your EC2 instance w/a browser and you should see the splash page.\n    1.  URL should be IP address/mvp/app1\n    1.  Visit IP address/mvp/app1/alpha/create/ to create a row in database\n        1. Note the URL changes after submit\n        1. Visit IP address/mvp/app1 and note that row is visible (click through row to edit)\n        1. Inspect urls.py for other features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguycole%2Fdjango-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguycole%2Fdjango-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguycole%2Fdjango-lab/lists"}