# A simple django app ## Libraries to install: sudo apt-get install python-dev sudo apt-get install libpq-dev sudo apt-get install python-pip sudo apt-get install git ## Setup DB setup DB here with db name=django_db: * sudo -u postgres createuser django_user * sudo -u postgres createdb django_db * psql -U postgres * ALTER USER django_user with password 'django_user'; * GRANT ALL PRIVILEGES ON DATABASE "django_db" to "django_user"; Edit: /etc/postgresql/10/main/pg_hba.conf Change the authentication for postges, find this line: * local all all peer and change peer to md5 ## Optional Virtual Env: An virtual env detour: * sudo apt-get install virtualenv * sudo apt-get install virtualenvwrapper * mkvirtualenv hlm ## Get django to initialise the db: * pip install -r requirements.txt * python manage.py syncdb ## Start django: * python manage.py runserver ## Add django to your init script: #### If you use `initctl`: Create a file like this: * cat /etc/init.d/hlm.conf ` start on runlevel [2345] stop on runlevel [!2345] exec /home/andy/.virtualenvs/hlm/bin/python /home/andy/happy-little-messages/manage.py runserver 7000 ` #### If you use `service`: Either add a file in /etc/init.d/ or launch with crontab -e To Update service control: * sudo chmod +x /etc/init.d/hlm * sudo chown root:root /etc/init.d/hlm * sudo update-rc.d hlm defaults * sudo update-rc.d hlm enable ## Restart Nginx [If using nginx]: * sudo service nginx restart