This article mainly introduces the Django framework running on Apache through mod_python configuration. Django is the most popular Pythonweb development framework. For more information about how to configure Django based on mod_python, install Apache with the available mod_python module. This usually means that there should be a LoadModule command in the Apache configuration file. It looks like this:
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
Then, edit your Apache configuration file and add Directive that ties a specific URL path to a specific Django installation. example:
SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug Off
Make sure that the mysite. settings project in DJANGO_SETTINGS_MODULE is replaced with the content corresponding to your site.
It tells Apache that any URL after the path/is processed using Django's mod_python. It passes the value of DJANGO_SETTINGS_MODULE to know which configuration should be used at this time.
Note that "'command instead of"' is used here "'. The latter is used to point to a location in your file system, however "'
System Message: WARNING/2 (
, line 403); backlinkInline literal start-string without end-string.System Message: WARNING/2 (
, line 403); backlinkInline literal start-string without end-string.System Message: WARNING/2 (
, line 403); backlinkInline literal start-string without end-string.System Message: WARNING/2 (
, line 403); backlinkInline literal start-string without end-string.System Message: ERROR/3 (
, line 405)Unexpected indentation.
Point to the URL of a Web site. "'
System Message: WARNING/2 (
, line 405); backlink Inline literal start-string without end-string. System Message: WARNING/2 (
, line 405); backlink Inline literal start-string without end-string.
Apache may not only run in the normal login environment, but also in different user environments. it may also have different file paths or sys. path. You need to tell mod_python how to find your project and Django location.
PythonPath "['/path/to/project', '/path/to/django'] + sys.path"
You can also add other commands, such as PythonAutoReload Off, to improve performance. View the mod_python document to obtain a detailed command list.
Note that you should set PythonDebug Off on the finished server. If you use PythonDebug On, your users will see ugly (and exposed) Python tracing information when an error occurs in the program. If you set PythonDebug to On, when mod_python has some errors, your users will see ugly (and some information will be exposed) Python's error tracking information.
After Apache is restarted, all requests to your site (or when you use After the command, it is a virtual host) will be handled by Djanog.