Install QGIS Server on windows
Here are all the steps you need to do to be able to install QGIS Server on Windows.
Step 1 Download
Start by downloading Osgeo4W installer https://qgis.org/en/site/forusers/alldownloads.html
For more instructions go to qgis official documentation at docs.qgis.org Getting Started
Select the following packages:
Step 2 Configure Apache
Open the following file
C:\OSGeo4W\apps\apache\conf\httpd.conf
Change the following lines
Current config | Replacement row |
---|---|
Define SRVPORT 80 |
Define SRVPORT 8080 |
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/" |
ScriptAlias /cgi-bin/ "C:/OSGeo4W/apps/qgis/bin/" |
#AddHandler cgi-script .cgi |
AddHandler cgi-script .cgi .exe |
# LoadModule foo_module modules/mod_foo.so |
LoadModule fcgid_module modules/mod_fcgid.so |
Apache permissions on folders
Find the following:
<Directory "${SRVROOT}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
Replace it with the following:
<Directory "C:/OSGeo4W/apps/qgis/bin/">
SetHandler cgi-script
AllowOverride None
Options +ExecCGI
Require all granted
</Directory>
Find the following:
<Directory />
AllowOverride none
Require all denied
</Directory>
Replace it with the following:
<Directory />
AllowOverride none
Require all granted
</Directory>
Custom OSGeo4W configuration variables
Find the following (probably at the bottom of the file):
IncludeOptional "C:/OSGeo4W/httpd.d/httpd_*.conf"
Add it here
SetEnv GDAL_DATA "C:/OSGeo4W/share/gdal"
SetEnv QGIS_AUTH_DB_DIR_PATH "C:/OSGeo4W/apps/qgis/resources"
SetEnv O4W_QT_PREFIX "C:\OSGeo4W/apps/Qt5"
SetEnv O4W_QT_BINARIES "C:\OSGeo4W/apps/Qt5/bin"
SetEnv O4W_QT_PLUGINS "C:\OSGeo4W/apps/Qt5/plugins"
SetEnv O4W_QT_LIBRARIES "C:\OSGeo4W/apps/Qt5/lib"
SetEnv O4W_QT_TRANSLATIONS "C:\OSGeo4W/apps/Qt5/translations"
SetEnv O4W_QT_HEADERS "C:\OSGeo4W/apps/Qt5/include"
SetEnv O4W_QT_DOC "C:\OSGeo4W/apps/Qt5/doc"
SetEnv PATH "C:\OSGeo4W\apps\qt5\bin;C:\OSGeo4W\bin;C:\OSGeo4W\apps\qgis\bin;C:\OSGeo4W\apps\grass\@grasspath@\bin;C:\OSGeo4W\apps\grass\@grasspath@\lib;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
SetEnv QGIS_PREFIX_PATH "C:\OSGeo4W\apps\qgis"
SetEnv QT_PLUGIN_PATH "C:\OSGeo4W\apps\qgis\qtplugins;C:\OSGeo4W\apps\qt5\plugins"
SetEnv TEMP "C:\Users\marlin\AppData\Local\Temp\4"
SetEnv PYTHONHOME "C:\OSGeo4W\apps\Python39"
SetEnv PYTHONPATH "C:\OSGeo4W\apps\Python39;C:\OSGeo4W\apps\Python39\Scripts"
SetEnv PROJ_LIB "C:\OSGeo4W\share\proj"
Step 3 Install apache web server as a Windows Service
Run the following: C:\OSGeo4W\bin\apache-install.bat
To restart the server run this: apache-restart.bat
Or you can go to the services in windows and search for the service called Apache OSGeo4W Web Server and restart it.