-
Notifications
You must be signed in to change notification settings - Fork 2
Windows Installation with IIS
Installing on Windows is a bit more difficult than on Linux, but can be done. Serving via IIS is theoretically possible, and will be tested during the creation of this document. This tool works best in Linux, and using an Ubuntu server is the preferred method. If that is not an option, perhaps WSL2 is an option, but will not be explored in this document.
Also note that certain features are NOT supported in a Windows installation, namely: accessing the PostgreSQL+PostGIS database from GIS software.
- A Windows Server (Tested on Windows Server 2019 and 2022)
- A text editor
- An internet connection
- A modern browser (Edge, Chrome, or Firefox, but NOT Internet Explorer)
-
Python 3.10+
- Download and run the latest Windows installable .exe
- Add Python 3.x to PATH
- When asked, disable 'path length limit' (expand the default character limit on PATH)
- Git
- PostgreSQL + PostGIS
- Download the latest VERSION 12 (not 14 or higher)
- Install all components
- Keep track of your password for user
postgres
- Keep the default port: 5432 (you may change this for additional security, but this document assumes this port)
- Keep track of your password for user
- Run "Stack Builder" to install PostGIS
- Select your new PostgreSQL v12 server for the target
- Expand options under 'Spatial Extensions' and check "PostGIS 3.2 Bundle"
- Accept all default options and agree to the GPL license
- Accept proposed changes to your Environment Variables
-
OSGeo4W + GDAL
- Download and run the installer
- Select 'Express Install'
- Select your mirror
- http://ftp.osuosl.org is recommended for most West Coast installations
- Select GDAL
This document assumes you will store the source code in a directory called C:/Apps/
. If you wish to install in Program Files
or another location, you will need to track your own changes throughout this document.
Downloading the source can be done using two methods:
- Git Bash (if you're comfortable with the command line)
cd /c/ mkdir Apps cd /c/Apps git clone https://github.com/Ecotrust/TEKDB.git
- Git GUI
- Select 'Clone Existing Repository'
- Source location: https://github.com/Ecotrust/TEKDB.git
- Target Directory:
C:\Apps\TEKDB
- Select 'Clone Existing Repository'
- Modify your OS Environment Variables from the command prompt
- This is scripted in the file
C:\Apps\TEKDB\scripts\Windows\set_osgeo_environment.bat
- If you installed OSGeo4W to anywhere other than C:\OSGeo4W, update the first line of that script to reflect your new location
- run
C:\Apps\TEKDB\scripts\Windows\set_osgeo_environment.bat
- This is scripted in the file
- Django + Environment
-
cd
to your application location:cd C:\Apps\TEKDB
- Create a virtual environment
py -m venv env
py -m pip install --upgrade pip
- Activate your virtual environment
env\Scripts\activate.bat
- Install requirements
pip install -r TEKDB\requirements.txt
-
Configure Local Settings (Text Editor, File Manager)
- Copy
C:\Apps\TEKDB\TEKDB\TEKDB\local_settings.py.template
toC:\Apps\TEKDB\TEKDB\TEKDB\local_settings.py
- Edit
C:\Apps\TEKDB\TEKDB\TEKDB\local_settings.py
so that it contains the following lines:ALLOWED_HOSTS = [ 'YOUR_URL', 'localhost', ] DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'tekdb', 'USER': 'postgres', 'PASSWORD': 'YOUR_POSTGRES_PASSWORD', 'HOST': 'localhost', 'PORT': '5432', } } GEOS_LIBRARY_PATH=r'C:\OSGeo4W\bin\geos_c' GDAL_LIBRARY_PATH=r'C:\Program Files\PostgreSQL\12\bin\libgdal-29' MEDIA_ROOT=r'C:\Apps\TEKDB\TEKDB\media' STATIC_ROOT=r'C:\Apps\TEKDB\TEKDB\static' DEBUG=True
- Be sure to update the following fields:
-
ALLOWED_HOSTS: replace this list of strings with your own intended URL(s) and/or IP Address
- A browser navigating to any address not in this list will not see the application
-
DATABASES:
- NAME: If you wish to use a different DB name you will gain very little security (through obscurity, only) but will likely have to adjust other steps in this document
- USER: Like name, you'll gain a little more security, but only if you expose your PostgreSQL port.
-
PASSWORD: This value should match the password you created when installing PostgreSQL above
- This will need to be wrapped in single-quotes, even if your password is numeric
-
ALLOWED_HOSTS: replace this list of strings with your own intended URL(s) and/or IP Address
You will create a database owned by the default 'postgres' user.
If you need additional security on your server, you can create a new PostgreSQL database user and make them the owner, updating your setting/configuration above and altering the steps below to match your username/password. You may also need to update additional PostgreSQL configuration files. This is beyond the scope of this document. It is recommended that if you need this level of security you proceed with the Linux installation.
This can be done in 2 ways, with a GUI or with the Command Prompt. We recommend the Command Prompt method.
-
Command Prompt:
psql -U postgres CREATE DATABASE tekdb; \q
-
GUI/pgAdmin4:
- Open pgAdmin4
- Create a 'master password'
- Log in providing the 'postgres' password created when installing PostgreSQL
- Expand 'Servers' -> 'PostgreSQL 12'
- Right click on 'Databases'
- Click on 'Create -> Database…'
- Name it 'tekdb' and save
- Open a command prompt
- Be sure you've activated your Python Virtual environment
- If so, you should see
(env)
before your prompt on each line
- If so, you should see
- run:
cd C:\Apps\TEKDB\TEKDB\ py manage.py migrate
- When done, you should see "Running migrations:" followed by a list of a few dozen lines reading something like "Applying xxx… OK"
- If you DO NOT see this, or get an error, double check that you created your database correctly, and that your local_settings.py file has DATABASES filled out correctly (case matters!)
- run:
py manage.py test TEKDB
- All tests should pass. If not, please reach out to the development team or open a ticket in GitHub
- run:
py manage.py loaddata TEKDB\fixtures\default_empty_database.json
- Ensure the
DEBUG=True
line is still in yourlocal_settings.py
file team or open a ticket in GitHub - run:
py manage.py runserver
- Open http://localhost:8000/ in a browser
- You should see the project homepage
- If not, review the installation steps, and if you can't debug, reach out to the development team or open a ticket in GitHub