The entire process of installing Django in Windows
1. install Apache
All the way to next, there is nothing to say, the main problem is that if multiple servers are installed, You need to modify the port number in the configuration file in HTTP. conf to change Listen 80 to listen 1234 to the port number you need
2 Python Installation
Python installation is also the same as next. After the installation is complete, it is found that python is not a so-called internal command. This indicates that the default installation process has not been completed. In the environment variable, put the python installation path in Path
3 Django Installation
After installing python, Django installation is also very simple. In the command line window, enter the folder decompressed by Django,
python setup.py install
The main task of this step is to copy some files required by Django to the Lib \ site_package \ Django directory of Python, including some source code
In this case, your Django has been installed successfully.
4. Create an app
Go to the Lib \ site_package \ Django \ bin directory that Django installed just now, where you want to put the file, for example, I put it in C: \ python26 \ Lib \ Site-packages \ Django \ bin
So I plan to put it on drive C.
Then directly run c: \ python26 \ Lib \ Site-packages \ Django \ bin \ django-admin.py start-Project mysite
At this time, a mysite folder is added to drive C, which is the newly added project.
Of course, you can also place the bin directory into the environment variable, so that you don't have to enter that directory every time so much trouble.
Go to the mysite directory and run
python manage.py runserver
If the operation is correct, you can see the Welcom to Django page in the browser.
The mysite directory contains the following files:
_ Init _. py is an empty file that tells Python that it is a python package.
Manage. py: This is a command line tool that enables you to interact with this project in multiple ways.
Settings. py: configure the Django project.
URLs. py is the URL declaration of this Django project.
4. install and use MySQL in the database
During installation, use utf8 as the default character set. Otherwise, Chinese garbled characters may easily occur.
Run Python manage. py syncdb after the installation is complete.
No module name mysqldb appears
Then I installed MySQL-python-1.2.2.win32-py2.6.exe.
It seems that this version of the installation file will contain a few fewer DLL files.
Libmmd. dll libmysql. dll libguide40.dll
You need to put it in the System32 directory or Python lib directory.
Finally, MySQL is successfully installed.
5 install mod_python
It seems that there is no major problem with the previous installation, but it is easy to solve it all the way to next, but it is very troublesome today ..
Mod_python does not support python2.6 for any reason.
After Google for a long time, I got this conclusion. Either I had to switch back to 2.5, or I had to compile it myself,
Used to find a very detailed document, I decided to compile it myself
The first step is to delete Apache because there is a problem with the default installation.
Two problems need to be noted during reinstallation
1. The installation path should not be under the default program file. Because Windows supports spaces as file names,
It brings a lot of trouble, so it is best to modify the installation path by yourself
2. Select the custom mode instead of the default mode, and then select "on" build headers and libraries "under" Apache RunTime ".
This is used when building mod_python.
I have made a lot of effort to make these two steps much easier.
Check out the mod_python source code.
The trunk URL is: https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk/
Modify row 171st in mod_python \ Dist \ setup. py. In
Ext_modules = [modpymodule, pspmodule]
To:
Ext_modules = [modpymodule] #, pspmodule]
Use the command line tool in vs2008.
Then go to the DIST directory
Set apachesrc = c: \ apache
Run build_installer.bat.
In this case, an installation file is generated under the DIST directory, and the installation file can be run directly.
After mod_python is installed, the configuration is complete.
Sethandler Python-Program
Pythonhandler Django. Core. Handlers. modpython
Setenv django_settings_module mysite. Settings
Pythonoption Django. Root/mysite
Pythondebug on
This tells Apache: "Use mod_python for any URL at or under '/mysite/', using the Django mod_python handler." It passes the value of django_settings_module so mod_python knows which settings to use.
Here we will tell Apache to use mod_python to parse the URL in/mysite/or below using python.