1

Need guides to set up mod_wsgi on Windows for my XAMPP Apache and Django project. I'm using Python 3.7.3(win32), Django 2.2.3 and Apache 2.4.39(win64). Errors appear when after i set "MOD_WSGI_APACHE_ROOTDIR=C:\xampp\apache\bin" and pip install mod_wsgi. I'm not sure what i did wrong at this step?

Read about Visual Code 14.0. Downloaded it and i still got error.

   ERROR: Command errored out with exit status 1:
     command: 'c:\program files (x86)\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CHEEHO~1\\AppData\\Local\\Temp\\pip-install-41s5l0d2\\mod-wsgi\\setup.py'"'"'; __file__='"'"'C:\\Users\\CHEEHO~1\\AppData\\Local\\Temp\\pip-install-41s5l0d2\\mod-wsgi\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CHEEHO~1\AppData\Local\Temp\pip-record-um32pphd\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\CHEEHO~1\AppData\Local\Temp\pip-install-41s5l0d2\mod-wsgi\
    Complete output (33 lines):
    c:\program files (x86)\python37-32\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\mod_wsgi
    copying src\__init__.py -> build\lib.win32-3.7\mod_wsgi
    creating build\lib.win32-3.7\mod_wsgi\server
    copying src\server\apxs_config.py -> build\lib.win32-3.7\mod_wsgi\server
    copying src\server\environ.py -> build\lib.win32-3.7\mod_wsgi\server
    copying src\server\__init__.py -> build\lib.win32-3.7\mod_wsgi\server
    creating build\lib.win32-3.7\mod_wsgi\server\management
    copying src\server\management\__init__.py -> build\lib.win32-3.7\mod_wsgi\server\management
    creating build\lib.win32-3.7\mod_wsgi\server\management\commands
    copying src\server\management\commands\runmodwsgi.py -> build\lib.win32-3.7\mod_wsgi\server\management\commands
    copying src\server\management\commands\__init__.py -> build\lib.win32-3.7\mod_wsgi\server\management\commands
    creating build\lib.win32-3.7\mod_wsgi\docs
    copying docs\_build\html\__init__.py -> build\lib.win32-3.7\mod_wsgi\docs
    creating build\lib.win32-3.7\mod_wsgi\images
    copying images\__init__.py -> build\lib.win32-3.7\mod_wsgi\images
    copying images\snake-whiskey.jpg -> build\lib.win32-3.7\mod_wsgi\images
    running build_ext
    building 'mod_wsgi.server.mod_wsgi' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\src
    creating build\temp.win32-3.7\Release\src\server
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\xampp\apache\bin/include "-Ic:\program files (x86)\python37-32\include" "-Ic:\program files (x86)\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc/server\mod_wsgi.c /Fobuild\temp.win32-3.7\Release\src/server\mod_wsgi.obj
    mod_wsgi.c
    C:\Users\Chee Hong\AppData\Local\Temp\pip-install-41s5l0d2\mod-wsgi\src\server\wsgi_apache.h(42): fatal error C1083: Cannot open include file: 'httpd.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\program files (x86)\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\CHEEHO~1\\AppData\\Local\\Temp\\pip-install-41s5l0d2\\mod-wsgi\\setup.py'"'"'; __file__='"'"'C:\\Users\\CHEEHO~1\\AppData\\Local\\Temp\\pip-install-41s5l0d2\\mod-wsgi\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\CHEEHO~1\AppData\Local\Temp\pip-record-um32pphd\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

I need to deploy my Django on Apache web server.

5
  • If you are using Apache 64 bit version, you need to compile your mod_wsgi with 64 bit version of python. Commented Aug 23, 2019 at 8:32
  • is it this python version : Windows x86 executable installer or Windows x86-64 executable installer? Commented Aug 23, 2019 at 8:44
  • 1
    x86 is the 32 bit version. You need to get this version : python.org/ftp/python/3.7.4/python-3.7.4-amd64.exe It might ask you the version you want to install, so you will have to choose the 64 bit. Commented Aug 23, 2019 at 11:17
  • okay thanks for your help but do you know what other problems i have got out here? :( Commented Aug 26, 2019 at 1:11
  • but my installation setup for python 3.7.3 is for 64-bits, i just checked Commented Aug 26, 2019 at 1:14

1 Answer 1

1

In windows apache configuration for Django project is slightly different than that of Ubuntu. We cannot find mod_wsgi.so module for windows to include it as LoadModule in apache httpd.conf. Alternatively we can do the following setup for successfully running Django project in apache server.

  1. Install latest version of apache

  2. download mod_wsgi source code from https://github.com/GrahamDumpleton/mod_wsgi

  3. Activate python virtual environment

  4. cd to mod_wsgi folder where it downloaded

  5. Run the following command python setup.py install

    mod_wsgi package is installed in python virtual environment

  6. Now some configuration has to be included in httpd.conf file of apache in order to run web app. So, run the following command mod_wsgi-express module-config

  7. output of the command is-

LoadFile "c:/path_to/python37.dll" LoadModule wsgi_module "d:/virtual_environment/lib/site-packages/mod_wsgi-4.7.1-py3.7-win-amd64.egg/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "d:/virtual_environment" Include the above in apache httpd.conf file.

  1. Now to run web app of django in apache, some more configuration has to be done at apache httpd.conf file. In windows running daemon process is not possible. So alternatively the httpd.conf setup information can be found in official link of django https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/modwsgi/

The set up is done and web app will run successfully in apache!!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.