Home >>Django Tutorial >Django Configuration with Apache Web Server

Django Configuration with Apache Web Server

Django Configuration with Apache Web Server

To run the web application Django uses its built-in development server. To start this server, we use the “python manage.py runserver” command.

This command starts the server which runs on port 8000 and can be accessed at the browser by entering localhost:8000.

But if we want to run our application by using the apache server then we need to configure the apache2.conf file located at /etc/apache directory. We have to add the following code in this file.

WSGIScriptAlias / /var/www/html/django7/django7/wsgi.py  
WSGIPythonPath /var/www/html/django7/  
<Directory /var/www/html/django7>  
   <Files wsgi.py>  
                Require all granted  
   </Files>  
</Directory>  

After adding these lines, we have to restart the apache server by using the "service apache2 restart" command and then type localhost to the browser's address bar. Now, the project will run on the apache server rather than a built-in server.