-
Notifications
You must be signed in to change notification settings - Fork 19
Deploying to PythonAnywhere
Zack Hable edited this page Mar 18, 2021
·
3 revisions
To deploy the site for the first time to PythonAnywhere (ie: you're setting up a dev account and want to test something remotely for some reason or replicate the "production" account).
- Sign up with PythonAnywhere (you should be able to use a free account)
- Setup a new webapp (opt for a basic Django template/site and Python 3.8+)
- SSH into the system (ie: ssh [email protected] for paid accounts) or use the provided console via the website (for free accounts)
- Remove any of the template site (ex:
rm ~/mysite
) - Clone this repo (
git clone https://github.com/CAASI-G2A/g2a-website.git
) - Add your web app url (Ex: user.pythonanywhere.com) and WSGI path to PPUC/def/settings.py (you can find the WSGI path from the pythonanywhere site under "Code" > "WSGI configuration file:")
- Setup a virtual environment for python in the user's home directory (ie:
python3.8 -m venv ~/venv
) - Activate the virtual environment (
source ~/venv/bin/activate
) - Install all python packages (
pip3 install -r g2a-website/PPUC/requirements.txt
) - Set the virtual environment path in the PythonAnywhere webapp page under "Virtualenv" (ie:
/home/USER/venv
)- You should also set the source code path too (ie:
/home/USER/g2a-website
) - Also set the static asset paths under "Static files:":
- /static/ -> /home/USER/g2a-website/PPUC/PxPUC/static
- /static/ -> /home/USER/g2a-website/PPUC/frontend/dist
- You should also set the source code path too (ie:
- Run the application setup script from the Django project directory (ie: in g2a-website/PPUC run
python3 manage.py runscript -v3 setup_app
) - Update the default WSGI file to use the correct Django settings and NPM version (you got this path earlier from the PythonAnywhere website)
- Set project home to
project_home = '/home/USER/g2a-website/PPUC'
- Change Django settings environment variable to
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'def.settings')
- Set project home to
- Reload the WSGI file from the PythonAnywhere web panel
- Check the website now