Django Apache Setup - Django WSGI | W3schools

Till now, in all our modules, we have been using the Django dev web server. But Django dev web server is used for testing purpose only. There will no involvement of the production environment. In such a scenario where you are required to get involved in the production then you should be using real servers such as Apache, Nginx, and several others. Well, this chapter will all be dedicated to Apache server only.

Also Read: Django Template System

Serving Django applications via Apache is performed with the help of mod_wsgi. So, it is important that you pre-install Apache and mod_wsgi before we proceed ahead. We hope you remember the structure of the project. Well, it looks like the following:




You can consider the file as the link between Django and Apache.

In here, we will be sharing our already created myproject project with Apache. For that purpose, you need to set the path so that Apache can access the myproject folder. For instance, you can consider the default path of the myproject folder as /var/www/html. Now, to access the project, enter the URL – The below screenshot will help you to understand how Apache will list out the folders involved.

django apache setup

You can clearly see that Apache is not involved in any of the Django’s stuff. But, if you want Apache to take care of these kinds of stuff too then you are required to configure Apache in httpd.conf. The httpd.conf file needs to be altered with the following content:


WSGIScriptAlias / /var/www/html/myproject/myproject/

WSGIPythonPath /var/www/html/myproject/

<Directory /var/www/html/myproject/>


     Order deny,allow

     Allow from all



Now enter the given URL – to get to the login page. The screen will appear as the following:

django apache login page