作者:窈窕眈眈 | 来源:互联网 | 2014-05-28 16:53
一、准备工作1、安装WindowsXP虚拟机虚拟机我用的是vmplayer5,直接安装可以省去此步骤2、下载所需要的安装包Nginxfowwindowshttp://nginx.org/download/nginx-1.2.5.zipDjangohttp://www.djangoproject.com/m/releas
一、准备工作
1、安装WindowsXP虚拟机
虚拟机我用的是vmplayer 5,直接安装可以省去此步骤
2、下载所需要的安装包
Nginx fow windows
http://nginx.org/download/nginx-1.2.5.zip
Django
http://www.djangoproject.com/m/releases/1.4/Django-1.4.2.tar.gz
python
python 许多的网址打不开,可以访问以下地址
http://www.python.org/getit/
这里下载python 2.7.3
http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi
还有python setup tools,他好,我也好
http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe
下载pymongo,官方推荐python连接mongodb的驱动,当然也可以用上面setup tools
easy_install pymongo
http://pypi.python.org/pypi/pymongo/#downloads
http://pypi.python.org/packages/2.7/p/pymongo/pymongo-2.3.win32-py2.7.exe
MongoDB
官网:http://www.mongodb.org
MongoDB windows 32平台的,可以根据自己的情况到以下网址下载,注意下载官方推荐用于生产环境的版本。
http://www.mongodb.org/downloads
http://downloads.mongodb.org/win32/mongodb-win32-i386-2.2.1.zip
二、开始安装
1、python 安装,一路next 即可,注意安装的路径,我的是
C:\python27,安装最后一步点击“Finish”,还需要将c:\python27加入到系统Path的环境变量当中。在CMD当中输入python命令,会显示python的版本和命令解释器提示符>>>,测试安装成功。
2、安装pymongo-2.3.win32-py2.7.exe和setuptools-0.6c11.win32-py2.7.exe,安装过程中会显示自动识别到python的路径,都是一路点击next完事,如果你安装多个版本的python,注意选择一下安装的python版本。真方便啊!
3、安装Django。将Django-1.4.2.tar.gz 安装包解压出来,里面有个install
的文档,用写字板打开来,如下:
Thanks for downloading Django.
To install it, make sure you have Python 2.5 or greater
installed. Then run
this command from the command prompt:
python setup.py install
AS AN ALTERNATIVE, you can just copy the entire "django"
directory to Python's
site-packages directory, which is located wherever your Python
installation
lives. Some places you might check are:
/usr/lib/python2.7/site-packages (Unix,
Python 2.7)
/usr/lib/python2.6/site-packages (Unix, Python
2.6)
/usr/lib/python2.5/site-packages (Unix, Python
2.5)
C:\\PYTHON\site-packages
(Windows)
For more detailed instructions, see docs/intro/install.txt.
翻译过来的意思就是在CMD当中切换到你解压的路径,输入 python setup.py install
,会显示许多的Copy信息,都copy到C:\Python27\Lib\site-packages\django当中去了,你可以把这个路径加入到系统Path环境变量,在C:\python27\scripts中也有一个django_admin.py,把C:\python27\scripts也加入Path。
测试一下安装是否成功:
在CMD当中输入python
>>> import django
>>> print django.get_version()
1.4.2
>>>exit()
安装成功。
测试一下Django是否正常工作。
重新打开CMD(因为环境变量配置以后需,CMD重启才有效)
c:\md djangotest
C:\>cd djangotest
C:\djangotest>django-admin.py startproject prj
C:\djangotest>dir
驱动器 C 中的卷没有标签。
卷的序列号是 2807-9638
C:\djangotest 的目录
2012-11-23 11:03
.
2012-11-23 11:03
..
2012-11-23 11:03
prj
0
个文件
0 字节
3 个目录 39,700,819,968 可用字节
C:\djangotest>cd prj
C:\djangotest\prj>python manage.py runserver
Validating models...
0 errors found
Django version 1.4.2, using settings 'prj.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[23/Nov/2012 11:04:40] "GET / HTTP/1.1" 200 1954
在IE当中输入http://127.0.0.1:8000/,会看到
It worked!
Congratulations on your first Django-powered page.
测试成功!
4、Mongodb安装
将安装包mongodb-win32-i386-2.2.1.zip解压到C:\,解压后名字太长,改成c:\mongodb
在mongodb目录下面有个readme,其中有:
To run a single server database:
$ mkdir /data/db
$ ./mongod
$
$ # The mongo Javascript shell connects to
localhost and test database by default:
$ ./mongo
> help
翻译成中文就是需要建立一个c:\data\db的文件夹,才能运行mongodb数据库
c:\md \data\db
c:\cd mongodb\bin
c:\mongodb\bin\mongod
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!出错了,晕,原来mongodb2.2不支持Windows
XP&2003了,下载2.0的最后的production版本吧!
http://www.mongodb.org/dr/downloads.mongodb.org/win32/mongodb-win32-i386-2.0.8.zip/download
重来一次
C:\mongodb\bin>mongod
mongod --help for help and startup options
Fri Nov 23 12:59:44
Fri Nov 23 12:59:44 warning: 32-bit servers don't have journaling
enabled by default. Please use --journal if you want
durability.
Fri Nov 23 12:59:44
Fri Nov 23 12:59:44 [initandlisten] MongoDB starting : pid=136
port=27017 dbpath=/data/db 32-bit host=2012-1119-1501
Fri Nov 23 12:59:44 [initandlisten]
Fri Nov 23 12:59:44 [initandlisten] ** NOTE: when using MongoDB 32
bit, you are limited to about 2 gigabytes of data
Fri Nov 23 12:59:44 [initandlisten]
** see
http://blog.mongodb.org/post/137788967/32-bit-limitations
Fri Nov 23 12:59:44 [initandlisten]
** with --journal, the limit is
lower
Fri Nov 23 12:59:44 [initandlisten]
Fri Nov 23 12:59:44 [initandlisten] db version v2.0.8, pdfile
version 4.5
Fri Nov 23 12:59:44 [initandlisten] git version:
a340a57af7cdda865da420704e1d1b2fac0cedc2
Fri Nov 23 12:59:44 [initandlisten] build info: windows
sys.getwindowsversion(major=6, minor=0, build=6002, platform=2,
service_pack='Service Pack 2') BOOST_LIB_VERSION=1_42
Fri Nov 23 12:59:44 [initandlisten] options: {}
Fri Nov 23 12:59:44 [initandlisten] waiting for connections on port
27017
Fri Nov 23 12:59:44 [websvr] admin web console waiting for
connections on port 28017
浏览器地址栏输入http://127.0.0.1:28017/打开web admin的界面。