Installing Mod - Wsgi On Windows: Install Python

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

installing mod_wsgi on

Windows
Install python
Download the python installer
from https://www.python.org/downloads/windows/ and execute it. Make sure that
it’s being installed for all users (it will install to C:\Program Files\Python ), you
might need to use the “Customize installation” option.

Once the process is done open a prompt and try running the following commands.

python -V

pip -V

It should print both the version of the python interpreter and the python installer.

Install the Visual C++ compiler


Download and install “Build tools for Visual Studio”
from https://visualstudio.microsoft.com/downloads/

Note that the “Visual C++ redistributable package” installs just the runtime
components. For this we need the build tools package.

For more information check https://wiki.python.org/moin/WindowsCompilers

Upgrade setuptools
Open a command prompt and run:

pip install --upgrade setuptools

Install mod_wsgi
If the Apache httpd instance is installed in a path other
than C:\Apache\Apache24 (Apache Lounge’s default installation path)
the MOD_WSGI_APACHE_ROOTDIR environment variable will need to be set. In this
case I had to set it to the following path C:\Program Files (x86)\Apache
Software Foundation\Apache

From within a command prompt run:

pip install mod_wsgi

If everything is alright it should just display a message announcing that the package
has been installed.

In my case it threw an error complaining about missing files in


the include directory. This directory contains the headers needed for compiling
the mod_wsgi module. This Apache httpd installation lacked some files and
contained a few extra ones when compared with an Apache Lounge release installed
in a test box. This issue was solved by copying the files from the Apache Lounge
release and running again the mod_wsgi install command. If you need to do this,
make sure that the major and minor versions of Apache httpd match.

Configure mod_wsgi
After installing the mod_wsgi package some configuration is needed.

In order to obtain the proper paths for we need to run the following command:

mod_wsgi-express module-config

It should return an output like:

LoadFile
"c:/users/eis/appdata/local/programs/python/python38/python38.dll
"
LoadModule wsgi_module
"c:/users/eis/appdata/local/programs/python/python38/lib/site-
packages/mod_wsgi/server/mod_wsgi.cp38-win_amd64.pyd"
WSGIPythonHome
"c:/users/eis/appdata/local/programs/python/python38"
This output will then need to be copied in the conf/httpd.conf file or other
relevant configuration file in the Apache httpd installation folder.

Upon restarting Apache httpd the server control window should now display a new
item in the status bar that reads “mod_wsgi”.

This should be enough to run a WSGI app with the module.

5. C:\xampp\apache\conf\httpd.conf

Set WSGIPythonPath "C:/xampp/htdocs/GISApi/GISApi "

** path with static files and apps

6. C:\xampp\apache\conf\ httpd-vhosts.conf

<VirtualHost *:83>

ServerName gisapi

DocumentRoot C:/xampp/htdocs/GISApi/GISApi

<Directory "C:/xampp/htdocs/GISApi/GISApi">

Options +Indexes +Includes +FollowSymLinks +MultiViews

AllowOverride All

Require all granted

</Directory>

Alias /static/ C:/xampp/htdocs/GISApi/GISApi/static/

<Directory "C:/xampp/htdocs/GISApi/GISApi/static">

Require all granted

</Directory>

WSGIScriptAlias / C:/xampp/htdocs/GISApi/GISApi/GISApi/wsgi.py

<Directory "C:/xampp/htdocs/GISApi/GISApi/GISApi">

<Files wsgi.py>

Require all granted


</Files>

</Directory>

</VirtualHost>

You might also like