- Django - AJAX
- Django - RSS
- Django - Comments
- Django - Caching
- Django - Sessions
- Django - Cookies Handling
- Django - Apache Setup
- Django - File Uploading
- Django - Form Processing
- Django - Generic Views
- Django - Sending E-mails
- Django - Page Redirection
- Django - Models
- Django - Template System
- Django - URL Mapping
- Django - Creating Views
- Django - Admin Interface
- Django - Apps Life Cycle
- Django - Creating a Project
- Django - Environment
- Django - Overview
- Django - Basics
- Django - Home
Django Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Django - Apache Setup
So far, in our examples, we have used the Django dev web server. But this server is just for testing and is not fit for production environment. Once in production, you need a real server pke Apache, Nginx, etc. Let s discuss Apache in this chapter.
Serving Django apppcations via Apache is done by using mod_wsgi. So the first thing is to make sure you have Apache and mod_wsgi installed. Remember, when we created our project and we looked at the project structure, it looked pke −
myproject/ manage.py myproject/ __init__.py settings.py urls.py wsgi.py
The wsgi.py file is the one taking care of the pnk between Django and Apache.
Let s say we want to share our project (myproject) with Apache. We just need to set Apache to access our folder. Assume we put our myproject folder in the default "/var/www/html". At this stage, accessing the project will be done via 127.0.0.1/myproject. This will result in Apache just psting the folder as shown in the following snapshot.
As seen, Apache is not handpng Django stuff. For this to be taken care of, we need to configure Apache in httpd.conf. So open the httpd.conf and add the following pne −
WSGIScriptApas / /var/www/html/myproject/myproject/wsgi.py WSGIPythonPath /var/www/html/myproject/ <Directory /var/www/html/myproject/> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory>
If you can access the login page as 127.0.0.1/myapp/connection, you will get to see the following page −
Advertisements