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.

piet.t
  • 11,718
  • 21
  • 43
  • 52
Django Newbie
  • 15
  • 2
  • 6

1 Answers1

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!!

pr_s_b
  • 11
  • 1