- Published on
Python Django - Host django project with XAMPP
- Authors
- Name
- The Bao Lu (beyonderluu)
- @beyonderluu
Hello everyone,
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. We usually run it by command line "python manage.py runserver", but today I'm gonna make a tutorial to run your django project with XAMPP.

First of all, you need to setup python (of course), XAMPP (any version with this link) and Visual C++ Build Tools (required)
Then Create your own django project, there are many tutorial about django on youtube that you can learn from. In this tutorial, I created my project with name "my_blog" and put it at Desktop.

Next step, set the Enviroment Variable for MOD_WSGI_APACHE_ROOTDIR to the path of apache. Here we are using XAMPP so I put it with "C:\xampp\apache"

Next step, install mod_wsgi package with following command: pip install mod_wsgi. Then, run the following command and copy all the result to anywhere, we will need for the next step: "mod_wsgi-express module-config"

Next step, look at the second line of the photo above "LoadModule wsgi_module ...". It take us to the file "mod_wsgi.cp37-win_amd64.pyd". Copy it to folder modules of apache "C:\xampp\apache\modules" and rename it and its extension ".pyd" to "mod_wsgi.so"

And the final important step, we will add some lines to Apache (httpd.conf). Go to the end of the file httpd.conf and copy these to yours:
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
WSGIScriptAlias / "C:/Users/BaoLT/Desktop/my_blog/my_blog/wsgi.py"
WSGIPythonPath "C:/Users/BaoLT/Desktop/my_blog"
<Directory "C:/Users/BaoLT/Desktop/my_blog">
<Files wsgi.py>
Allow from all
Require all granted
</Files>
</Directory>
WSGIPythonHome "C:/Users/BaoLT/appdata/local/programs/python/python37"
Alias /media/ C:/Users/BaoLT/Desktop/my_blog/media/
Alias /static/ C:/Users/BaoLT/Desktop/my_blog/static/
<Directory C:/Users/BaoLT/Desktop/my_blog/static>
Allow from all
Require all granted
</Directory>
<Directory C:/Users/BaoLT/Desktop/my_blog/media>
Allow from all
Require all granted
</Directory>
</IfModule>
In this tutorial, I put my project in desktop so you should change the path to your project and the path to your python version. If you don't have a static or media file, you can delete its lines.