Set up a virtual environment at the root of the project:
python3 -m venv venv
Activate the virtual environment:
source venv/bin/activate
Install dependencies:
pip3 install -r requirements.txt
mysqlclient depends on mysql-client being available.
brew install mysql-client
Copy example.env and rename to .env. Supply values in accordance with django-environ.
Follow these instructions to create a Django 2 project, but instead of installing Django and creating a new project, git clone this repository and pip3 install - r requirements.txt.
A working passenger_wsgi.py file looks something like this
import sys, os
INTERP = "/home/USERNAME/SITENAME.com/venv/bin/python3"
#INTERP is present twice so that the new python interpreter
#knows the actual executable path
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(cwd + '/PROJECTNAME') #You must add your project here
sys.path.insert(0,cwd+'/venv/bin')
sys.path.insert(0,cwd+'/venv/lib/python3.7/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = "PROJECTNAME.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
In the project directory, copy example.env to .env and supply the production values.
To deploy updates:
- Back up database
git fetchandgit pullto update the codebase on the server- Update
.envas necessary from the update - Activate the virtual environment
- Run
pip install -r requirements.txt - Run
python manage.py migratefrom the project directory - Run
python manage.py collectstaticfrom the project directory (is this a required step?) - Run
systemctl --user restart orangegnometo restart the gunicorn service