Similar to PHP, in order for Apache to be able to handle Python scripts (in fact, Apache cannot handle the script, just use other extensions to handle the script), it is necessary to install the appropriate extension module for Apache.
The original Python extension of Apache was mod_python.so this module, but later because it was not updated maintenance, so most of the use of mod_wsgi.so this module.
Another: Wsgi is a proprietary Python protocol that defines how the server communicates with the Python interpreter.
Deployment First step: Install MOD_WSGI module for Apache expansion
sudo apt-get install Libapache2-mod-wsgi
Once the installation is complete, it will automatically help you set up the necessary soft connections for Apache. (that is, there is no need to manually write a loadmodule mod_wsgi or something like that)
(Libapache2 has n more modules, should be able to install this, do not have to manually download the online)
Deploy the second step: give Apache a configuration file, specify the root directory, and explain to whom the request is handled:
The first line of Wsgiscriptalias indicates that the root directory of the Web site is visited or/home/lisong/lisongsite/django.wsgi processed. (Also note: My project in/home/lisong/lisongsite)
The second line to the future, is the normal Apache granted directory access to the thing.
Deploy step three: give Django a request to receive a file, receive a request from Apache, and distribute it to the appropriate URL for processing.
This script is broadly divided into two parts:
The first part, the project path, the application path under the project is added to the path. In fact, the first and second parts are a goal, in order for Django to find the appropriate project path, script, and so on.
The second part, indicates the path of the django_setting_module, so that the request can come in, according to the path to find the settings and do the corresponding distribution processing. All the settings for the project are settings this place.
Finally, restart Apache and the browser will be able to access the machine IP.
If there is a problem, such as newspaper 500 wrong, you can look at the Apache error log, very useful. /var/log/apache2/error.log
Deploying Django on Apache