6

I had apache 2.4 already installed with xampp.I tried adding mod_wsgi using the steps mentioned here

But when I add the line

LoadModule wsgi_module modules/mod_wsgi-py34-vc10.so

Apache does not start.

Yadynesh Desai
  • 231
  • 1
  • 5
  • 13

5 Answers5

12

It is better to build mod_wsgi yourself from code rather than use an arbitrary binary off the net. The steps are as follows.

  • Ensure you have a decent Apache installation which includes header files, e.g. Apache 2.4.37 Win64 from Apache Lounge . Preferably installed at location of C:/Apache24.

  • Ensure your Python installation is set up so that you can pip install modules. This must include having the correct Microsoft C compiler needed by that Python version.

  • Run pip install mod_wsgi. If your Apache installation is not at C:/Apache24, then first set the environment variable MOD_WSGI_APACHE_ROOTDIR to its location. Ensure you specify path as C:/Apache24 form and not with back slashes, that is, not as C:\Apache24. This is only needed when doing the install, not later.

  • Run mod_wsgi-express module-config.

  • Copy the output from runing mod_wsgi-express module-config into your Apache configuration file.

  • Add configuration for a WSGI application to the Apache configuration.

  • Restart Apache and see if it works.

Note that you are better off starting with a WSGI hello world rather than some huge Django application when initially testing.

Serge Rogatch
  • 13,865
  • 7
  • 86
  • 158
Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Thanks.I started learning Django instead.Using their server for now – Yadynesh Desai Mar 07 '17 at 13:44
  • 2
    When I run `pip install mod_wsgi` it fails with `c:\apache24\include\apr_network_io.h(29) : fatal error C1083: Cannot open include file: 'apr_perms_set.h': No such file or directory'.` This is with httpd 2.4.27. Any ideas how to fix that? – Larry Martell Aug 13 '17 at 16:11
  • The above attempt was with source I downloaded from `http://mirrors.gigenet.com/apache/httpd/httpd-2.4.27.tar.gz`. I just tried building with source cloned from github and that failed with `c:\apache24\include\ap_hooks.h(39) : fatal error C1083: Cannot open include file: 'apr.h': No such file or directory` – Larry Martell Aug 13 '17 at 16:42
  • I thought this was the same question, and I tried your solution and I had issues. That is why I asked in the comments. I will create a new question. – Larry Martell Aug 13 '17 at 20:45
  • "first set the environment variable MOD_WSGI_APACHE_ROOTDIR to its location". How is this done? – Chris Nielsen Aug 23 '17 at 01:28
  • That depends on what shell you are using on Windows. Have you looked up "How to set environment variable from shell in Windows"? – Graham Dumpleton Aug 23 '17 at 01:47
  • 1
    in windows cmd setting the environment variable is done via `set MOD_WSGI_APACHE_ROOTDIR=c:/path/to/apache` Note that it will be unset as soon as you close the cms – Simon Zyx Oct 18 '18 at 10:25
  • You might have to install visual studio build tools for this to work. These can be found on the https://visualstudio,microsoft.com/downloads/ under tools. In the following menue you have to choose cpp build tools and of those you only need the windows 10 sdk (around 4.5 GB) – Simon Zyx Oct 18 '18 at 10:28
  • 1
    I've posted a question about the missing include files: https://stackoverflow.com/questions/54268396/cannot-open-include-file-apr-perms-set-h-when-doing-pip-install-mod-wsgi – Serge Rogatch Jan 19 '19 at 15:03
  • Where to add the return of the mod_wsgi-express module-config cmd in the httpd.conf? Do I open a directory for this, or do I have to add it to some existing one in the file? The document doesnt clarify it. – ReinholdN Jan 19 '20 at 04:27
3

Use the release of Apache Lounge , if you still find c:\apache24\include\apr_network_io.h(29) : fatal error C1083: Cannot open include file: 'apr_perms_set.h': No such file or directory'. . This is best fit to Windows.

L.ZH
  • 31
  • 3
2
This topic is useful for Windows 10, xampp webserver as well.
I was struggling to find precompiled mod_wsgi.so for 
Apache/2.4.27 (Win32) 
Python/2.7.13 
This [link][1] is useful to find the appropriate version of mod_wsgi.
IF you are lucky, you can find the precompiled version [here][2]
There is a step by step guidance available [here][3]


  [1]: https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst
  [2]: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
  [3]: https://everything2.com/title/Installing+Python+on+XAMPP
Purushothaman
  • 417
  • 4
  • 6
  • 1
    The recommended method is to build it yourself using ``pip install mod_wsgi`` as explain in another answer. Grabbing arbitrary binaries is not guaranteed to work. You should build it for your specific Apache installation. – Graham Dumpleton Sep 15 '17 at 13:41
  • 1
    https://www.lfd.uci.edu/~gohlke/pythonlibs/ saved me a lot of time getting the VC compiler toolchain on my machine. Basically `pip install <.whl file>`, then continue following the instructions here: https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst – solstice333 Aug 04 '18 at 09:56
1

@LarryMartell I met the same issue on windows and fixed it. You can try to copy file apr_perms_set.h from apr repository (https://github.com/traviscross/apr) to Apache2.4's include folder.

ZMJ
  • 337
  • 2
  • 11
  • This doesn't answer the original question. Copying APR header files from a separate repo is also not guaranteed to work anyway if the issue was they were missing. Use a Apache distro which ships header files instead. If you aren't use the exact same header files as the Apache was compiled with, you can encounter problems. – Graham Dumpleton Oct 04 '17 at 04:46
1

I am using a 64 bit operating system and have 64 bit python installed.

installing apache distribution for 64 bit OS from apachelounge https://www.apachelounge.com/download/ resolved the problem for me.

Ohia George
  • 151
  • 2
  • 11
  • Yes, this is the only solution I've found so far. A question stays how to fix it for ApacheHaus: https://stackoverflow.com/questions/54268396/cannot-open-include-file-apr-perms-set-h-when-doing-pip-install-mod-wsgi – Serge Rogatch Jan 19 '19 at 15:23