Steps to Deploy Python Django Application on Windows Server

Sahil Soni
Oct 11, 2020 · 3 min read

1) Install Wamp

2) Install Visual Studio for C++

https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15#

3) Install mod_wsgi using following Steps:

a. Open Command Line as administrator

b. Write Following command

c. C:\Windows\system32>set “MOD_WSGI_APACHE_ROOTDIR=C:\wamp64\bin\apache\apache2.4.46”

d. In above command , Please update address according to your computer.

4) Get mod_wsgi path by writing following command . This path is required to update in wsgi file.

a. mod_wsgi-express module-config

5) Update httpd.conf file:

a. Go to following path , according to your system:

i. C:\wamp64\bin\apache\apache2.4.46\conf

ii. Open httpd.conf file

b) Scroll to bottom of httpd.conf file and paste following code:

# Apache httpd.conf settings

LoadModule wsgi_module “C:/Users/hp1/AppData/Local/Programs/Python/Python37/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd”

WSGIScriptAlias / “D:/SHARE/ui_demo/ui_demo/wsgi.py”

WSGIPythonHome “c:/python36”

WSGIPythonPath “ Root Directory of Django Application”

Alias /media/ D:/SHARE/ui_demo/media/

Alias /static/ D:/SHARE/ui_demo/static/

1) LoadModule wsgi_module :

a. Please Note , use forward slash in path address

b. Go to following path according to your computer:

i. C:\Users\hp1\AppData\Local\Programs\Python\Python37\Lib\site-packages\mod_wsgi\server

c. WSGIScriptAlias : This path is for django application wsgi file

d. WSGIPythonHome : This path is for python library

e. WSGIPythonPath : Root Directory of Django Application

f. Alias /media/ D:/SHARE/ui_demo/media/ :These are path of static files like javascript folder and image folder in Django Application

2) Add following lines at bottom of httpd.conf files, these are for granting access to server for static folder

<Directory “D:/SHARE/ui_demo/media/”>

Require all granted

</Directory>

<Directory “D:/SHARE/ui_demo/ui_demo >

<Files wsgi.py>

Require all granted

</Files>

Require all granted

</Directory>

6) Add Hostname in settings.py File of Django Application

a. In hostname add

ALLOWED_HOSTS = [‘localhost’]

Django settings.py file

7) Run Wamp Server

a. Double click Wamp Icon and run as administrator ( No error Should Come)

b. After double clicking the Wamp server icon , a new popup will come at bottom right of start bar:

Run Wamp Server

c. Click on Localhost to run server.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…