Python3.3.0+apache2.4.4+django1.5.4+mod_wsgi3.4安装

来源:互联网 发布:女生用的吉他淘宝 编辑:程序博客网 时间:2024/06/11 23:46

系统环境

win7 64位

Python3.3.0安装

从官方网络上下载python3.3.0的安装包(http://www.python.org/download/),下载完成后和普通的Win程序一样安装就行了。

安装完成后在命令运行窗口中输入python -V

C:\Users\Tom>python -VPython 3.3.0
如果出现以上信息就说明安装成功了。

否则就要在环境变量中设置Python目录 ,把python目录设置在path环境变量下如

Path=E:\tools\eclipse\eclipse-3.7.1\jdk1.6.0_20\bin\;D:\Program Files (x86)\Android\android-studio\bin\;D:\Python33;E:\tools\eclipse\eclipse-3.7.1\jdk1.6.0_20\bin;E:\tools\eclipse\eclipse-3.7.1\jdk1.6.0_20\jre\bin;D:\Python33;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\TortoiseSVN\bin


Django1.5.4安装

从官方网络上下载django1.5.4的安装包(https://www.djangoproject.com),解压压缩包后在根目录下,启动命令行窗口输入

python setup.py install命令,系统将自动安装完成。

检查django是否安装成功,输入python命令,进入python控制台,在输入python代码import django运行(回车)如果没有出现

ImportError: No module named错误,则表示Django安装成功。

还可以查看django的版本。输入Django.VERSION回车将输出(1, 5, 4, 'final', 0)

C:\Users\Tom>pythonPython 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import django>>> django.VERSION(1, 5, 4, 'final', 0)>>>

Apache2.4.4安装

从官方网络上下载apache2.4.4的安装包(http://httpd.apache.org/),下载完成后和普通的Win程序的安装方式一样。

要注意的是Network Domain要填写你的网络域名,如果你的网络域名为voworld.sinaapp.com就将此域名填入,如果没有

也可以写本地的名称location。

Server Name要填写你的服务器名称,如果你的服务器名称为www.voworld.sinaapp.com就将此填入,如果没有

也可以写本地的名称location。

Administrator`s Email Address填写一个合法的email地址就可以了。

就算填错也是没有关系的,这些都是可以后期在配置里修改的,详情可以去查询官方文档。


mod_wsgi安装

mod_wsgi其实是一个apache的插件可以此下载(http://www.lfd.uci.edu/~gohlke/pythonlibs/),下载完成后解压,把里

面的mod_wsgi.so拷贝到apache的\modules\的目录下面。

然后找到apache的\conf\目录下的httpd.conf文件,打开在此文件中加入

LoadModule wsgi_module modules/mod_wsgi.soWSGIScriptAlias /py "D:/www/py/index.wsgi"Alias /py/static/ "D:/www/py/static/"<Directory "d:/www/py/">     Order allow,deny     Allow from all </Directory>

测试

在d:/www/py/目录下新建一个index.wsgi文件。在此文件中加入以下代码 。

def application(environ, start_response):    status = '200 OK'    output = 'Hello World!'    response_headers = [('Content-type', 'text/plain'),                        ('Content-Length', str(len(output)))]    start_response(status, response_headers)  return [output]

然后(重新)启动apache服务器。打开浏览器输入http://127.0.0.1/py 如果页面输入Hello World!则表示wsgi安装成功。

原创粉丝点击