The question is divided into the following steps
1. Install Python
2. Install Django
3. Install WSGI, if you have any questions, please refer to the previous Ubuntu compilation installation Mod_wsgi
4. Integration with Apache here is mainly about this part
Environment Apache 2.4.7 higher than this version applies to this configuration if the version is different, but there are problems that can be tried on other
1. Add Wsgi in Apache's module
I'm here to add a file in/etc/apache2/mods-available
Wsgi.load content is as follows:
LoadModule wsgi_module/usr/lib/apache2/modules/mod_wsgi.so
2.sudo A2enmod Wsgi
This step indicates that MOD_WSGI does not exist
The answers to the online search are as follows:
Execute: sudo apt-get install Libapache2-mod-wsgi
Execute sudo a2enmod wsgi again
At this time because I manually create a new file will be prompted whether to overwrite the selection is on the mods-available will be able to add two files at the time of Wsgi.load and wsgi.conf
3. Configure WSGI
"""WSGI config for Testdjproject project. It exposes the WSGI callable as a module-level variable named ' Application '. For more information on the this file, seehttps://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/"""ImportOSImportSyspath='/usr/bin/testdjproject'ifPath not inchSys.path:sys.path.append ('/usr/bin/testdjproject') Sys.path.append ('/usr/bin/testdjproject/testdjproject') Os.environ.setdefault ("Django_settings_module","testdjproject.settings") fromDjango.core.wsgiImportget_wsgi_applicationapplication= Get_wsgi_application ()
The site path needs to be added to the system path. The possible errors and doubts are as follows
1. No module named Testdjproject.settings this error is due to the fact that the path is not added to the wsgi.py configured below to cause the module to be found
2. To add access to 127.0.0.1 and localhost in the setting.py, see the following:
allowed_hosts = [' 127.0.0.1 ', ' localhost ']
3. Why this is testdj.setting this is the same as the site name
4. Do not add any parameters that need to be accurate after the path.
4. Configure Apache2
Because I this other site is in 000-default in order to get out convenient to troubleshoot new django.conf
The contents are as follows:
<virtualhost *: ->Alias/media//usr/bin/testdjproject/media/<Directory/usr/bin/testdjproject/media/>#Order Deny,allow #Allow fromAll Require all granted</Directory>Wsgiscriptalias//usr/bin/testdjproject/testdjproject/wsgi.py #WSGIPythonPath/usr/bin/testdjproject/Testdjproject<Directory/usr/bin/testdjproject/testdjproject>Options followsymlinks#allowoverride all### Order deny,allow### deny fromAll#order Allow,deny#allow fromall#satisfy All # options-Multiviewsrequire All granted<files wsgi.py>Order deny,allow allow from All</Files> </Directory></VirtualHost>
Here are a few questions 1. If the client denied by server is prompted after the configuration is complete: it may be possible to troubleshoot with require all granted
2. Invalid command ' Wsgiscriptalias ' Prompt This is WSGI module is not installed correctly please refer to the above
3. Wsgiscriptalias//usr/bin/testdjproject/testdjproject/wsgi.py This file is newly created in the Web site root directory settings can be
4. Note the permissions of the wsgi.py, if the permissions are not correct also error, this time to view the apache2 error log can I here is/var/log/apache2/error.log
5. Restart Apache Open the browser and the page you developed earlier will appear, so everything is fine. Do not necessarily match all errors, if there is a problem please read the log carefully and do again. Start is also installed after nothing, the original is to forget to add listening port this step or not less Listen 89
Ubuntu Apache2 Wsgi Deploying Django