How to Use Django with Apache and mod_python

Source: Internet
Author: User

OS: Ubuntu 10.04

DJANGO: Version 2.5

Apache: 2

Python: 2.6.

1. Install python, Django, Apache, mod_python

Apt-Get install

2. Edit httpd. conf

<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/">      AllowOverride None      Options None      Order allow,deny      Allow from all  </Directory>  Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"<Location "/mysite">    SetHandler python-program    PythonHandler django.core.handlers.modpython    SetEnv DJANGO_SETTINGS_MODULE mysite.settings    PythonOption django.root /mysite    PythonInterpreter mysite    PythonDebug On    PythonPath "['C:/Python/Django/apps'] + sys.path"</Location>

Location "/mysite" instead of location "/mysite /"

SetMaxrequestsperchild 1In this way, you do not need to restart Apache for testing during the development phase.

Alias/Media/is required on the Django admin Management Interface

Another method

cd /var/wwwsudo ln -s  ~/media mediasudo ln -s ~/django_src/django/contrib/admin/media admin_media# Absolute path to the directory that holds media.# Example: "/home/media/media.lawrence.com/"MEDIA_ROOT = '/home/YOUR_USERNAME/media/'# URL that handles the media served from MEDIA_ROOT. Make sure to use a# trailing slash if there is a path component (optional in other cases).# Examples: "http://media.lawrence.com", "http://example.com/media/"MEDIA_URL = 'http://yourdomain.com/media/'# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a# trailing slash.# Examples: "http://foo.com/media/", "/media/".ADMIN_MEDIA_PREFIX = '/admin_media/'

The path used is the opposite path.

If the data type is sqllite3, databasename should also be opposite

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.