How to Build Apache + MySQL + Python + Django in Windows

Source: Internet
Author: User
Tags install django tortoisesvn
  Software List:

The software version used in this article is as follows::

Python-2.5.2.msi

Apache_2.2.10-win32-x86-no_ssl.msi

Django-1.0.2-final.tar.gz

Mod_python-3.3.1.win32-py2.5-Apache2.2.exe

Mysql-5.1.37-win32.msi

Step 1: Install Python

Download from the python official website, such as 2.5.2.

http://www.python.org/download/releases/2.5.2/
download python-2.5.2.msi

The latest version2.5,X86SeriesCPUInstallationPython-2.5.2.msi, amdSeriesCPUInstallation: Python-2.5.2.amd64.msi

PythonInWindowsThe environment variables are not automatically registered after installation, so you can directly typePythonIt does not startPythonCommand LineProgramIn this case, you need to register in the systemPythonEnvironment variable.

PythonThe installation path of is

C:/python25

Environment Variable registration:

My computer->Attribute->Advanced->Environment Variable->System Variables

Double-clickPathItem, modifyPathIs

C:/python25;

Check whether the installation is successful

Run-Cmd, InputPython.PythonThe installation is successful.

Step 2, Install Django

http://tortoisesvn.sourceforge.net/ download tortoisesvn

Check outHttp://code.djangoproject.com/svn/django/trunk/django

Copy DjangoToC:/python25/lib/Site-packages/

Copy C:/python25/lib/Site-packages/Django/bin/django-admin.pyToC:/python25/scripts.

CMD,TypePython

>>> Import Django <br/> Django. version <br/>

Add system environment variables:
C:/python25/lib/Site-packages/Django/bin;

Normally, you can seeDjangoVersion Information

Step 3,Install apache2

Download from Apache Official Website

Http://archive.apache.org/dist/httpd/binaries/win32/ 

 

Step 4,Install mod_python-3.3

InstallMod_pythonWhen selectingApacheInstallation path

Mod_python, MySQL-PythonThe two modules are automatically installed..

 

Http://apache.justdn.org/httpd/modpython/

 

EditingApacheConfiguration File Httpd. conf
Add :
Loadmodule python_module modules/mod_python.so </P> <p> <location "/mysite/"> <br/> sethandler Python-Program <br/> pythonpath "sys. path + ['d:/Django '] "<br/> pythonhandler Django. core. handlers. modpython <br/> setenv django_settings_module myproject. settings <br/> pythoninterpreter mysite <br/> pythondebug on <br/> </location> </P> <p>

 

RestartApache,Open your browser,Type
Http: // localhost: 8000/mysite/

We can see thatWelcome to DjangoPage.At this time, your settings are successful..

AddMediaStatic directory support

CMD
D:/Django/myproject> mkdir Media

MediaDirectory StorageCSS, IMG, JSFile

Media |-CSS
|-Img
|-Js

AvailableHttp: // localhost/site_media/Direct access to style sheets,Images and other files.

EditingHttpd. conf

Add

 Alias/site_media D: /Django/myproject/media <br/> <location "/site_media/"> <br/> sethandler none <br/> </location> </P> <p> <locationmatch "(? I)/. (JPG | GIF | PNG | TXT | ICO | PDF | CSS | JPEG) $ "> <br/> sethandler none <br/> </locationmatch>

 RepeatApache

InD:/Django/myproject/MediaAddCSSFile,You can use

Http: // localhost/site_media/

It is bestApacheIn the configuration file

Maxrequestsperchild 0

Change

Maxrequestsperchild 1

Step 5 install MySQL

Http://mysql.mirrors.pair.com/Downloads/MySQL-5.1/mysql-5.1.37-win32.msi

After installation, you can configure config.

Enter command line, and enter the password first.

This section describes several common commands for MySQL:

 

Mysql> Create Database db1; <br/> # create a database; <br/> mysql> show databases; <br/> # view the database in the system; <br/> mysql> Use db1; <br/> # specify the name of the database to be operated; <br/> mysql> Create tables tab1; <br/> # create table tab1 in the db1 database; <br/> mysql> show tables; <br/> # view the number of data tables contained in the db1 database; <br/> mysql> drop database db1; <br/> # delete database db1; <br/> mysql> drop table tab1; <br/> # Delete table tab1 in the db1 database; <br/> mysql> DESC tab1; <br/> # view the structure of the tab1 table; <br/> mysql> select * From tabl; <br/> # view all items in table tab1;

For more information about SQL operations, see.

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.