ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to install \ deploy django on Xampp webserver with wsgiscriptalias on windows

Updated on September 10, 2012
Django - web framework
Django - web framework

1. Installing XAMPP for Windows

The most common web server to use MySQL, PHP or Perl application is Apache. Many websites use this server – it’s stable, well documented and it’s open-source. Of course you can use Apache as well, and learn all the things about running and maintaining web server and MySQL database. But if you need an “easy to use” and portable web server and still learn all the things about Apache you should consider XAMPP.

You can download XAMPP here. It’s really easy to install it, it’s well documented and it has installer or zip version.

As the installation process is vary well documented, we wouldn't focus on that now.

2. Installing python

Apache itself does not work as python (or django) server, so we need to configure it for our purpose. First thing to do is installing python on our server. You can download it from here. You should download the latest stable version. You should with version 2, until you would read that version 3 is fully supported by Apache and django. Python goes with Windows installer, so it shouldn’t be a problem to install it. Just follow the instructions on the screen. Remember to install Python for all users, because it wouldn’t work with Apache server. Apache server is run on special, system user and it needs access to your python files.

After installing Python you should add a path to python.exe to your system PATH variable.

3. Installing mod_wsgi

We would use python through cgi scripts, and for that we would need to install mod_wsgi. You could get raw version from project website here or compiled version with .so extension - here .Make sure, that you use a right version for your python and apache server.

You should place a file in apache modules folder – xampp\apache\modules and change it’s name for .Next you have to locate and change apache configuration file - \xampp\apache\conf\http.conf. Edit it and at the end of LoadModule section add a line:

LoadModule wsgi_module modules/

At this point we should create a folder for our application. It is the best practice, to set up a folder away from root web folder (not in xampp\htdocs). I’ve created one directly at partition d:\django-app .

Now we have to show our apache server where we store python scripts and how it should use it. In configuration file http.conf we search for “<Directory>” section. At the beginning we have there:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

Under that we add a WSGI handler with a line:

WSGIScriptAlias /wsgi "d:/django-app/"

It means that we will use file in d:/django-app for handling request from http://localhost/wsgi . The part /wsgi is the part after localhost in web browser address.

Next we have to set permissions to application folder, so no one could edit it. We do it by adding another <Directory> section:

<Directory "d:/django-app">
	AllowOverride None
	Options None
	Order deny,allow
	Allow from all

Remember that in Apache we change all “\” on “/” in Windows paths.

No we set up our test handler by creating file at d:/django-app .

Inside we should put this code:

def application(env, start_response):
    start_response("200 OK", [])
    output = "<html>Hello World! Request: %s</html>"
    output %= env['PATH_INFO']
    return [output]

We can test if it works opening http://localhost/wsgi in web browser.

4. Installing django

We should also install django. Download it from here and unpack. Installing django is done by python script, so we have to use command line. Press start and write cmd in search box (Run in other versions of Windows), then press Enter. A command line console would appear. Move to django directory by using change directory command and run the installer by typing:


You would be asked if you would like to create superuser.

Do it - we will use the user and password to get to admin panel later in the project

To check django installation write:

>>>import django
>>>print django.get_version()

Now you can add a PATH to your django installation in python. Django is installed as a python library in Lib\site-packages\django\ in python directory. Add this folder to your system PATH.

5. First django project

To start django project use: startproject SimpleCRM

It will creates a folder for a project and initial files. It is important to be at the folder that would be used for django applications (in our case it is d:\django-app)

Now we would edit for using django. Delete previous content an put this code:

import os
import sys

path = 'd:/django-app'
if path not in sys.path:

os.environ['DJANGO_SETTINGS_MODULE'] = 'SimpleCRM.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Now check results at http://localhost/wsgi/


    0 of 8192 characters used
    Post Comment
    • profile image


      15 months ago

      not clear

    • profile image


      6 years ago

      perfect, im gonna try this. thanks very much.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)