windows下安装apache + python + django + mod_wsgi.so
时间:2011-09-20
来源:互联网
对应版本:
Apache:Apache HTTP Server (httpd) 2.2.19
Python:Python2.7
Django:Django-1.3
Mod_wsgi.so:mod_wsgi-win32-ap22py27-3.3.so
1、下载相应Python和Apache版本的mod_wsgi.so,比如:
mod_wsgi-win32-ap22py27-3.3.so – Apache 2.2 / Python 2.7
2、下载只有一个文件:mod_wsgi.so,如果文件不是该文件名,请修改文件名。将该文件拷贝到Apache的modules目录
3、Apache的httpd.conf文件中最后加入以下两行:
LoadModule wsgi_module modules/mod_wsgi.so
Include “C:/Python27/code/gp/apache/apache_django_wsgi.conf”
第一行是让apache加载mod_wsgi模块
第二行是让apache加载web应用程序的配置文件,其中apache_django_wsgi.conf这个文件可也可以在httpd.conf文件里面,这样提取出来有利于维护。
4、创建django程序,比如我上面的gp程序放置在“C:/Python27/code/”里面。
5、在gp目录下创建一个apache文件夹,里面有两个文件:apache_django_wsgi.conf和django.wsgi。
apache_django_wsgi.conf文件内容:
# 设置django admin静态资源的访问路径
Alias /static/ “C:/Python27/code/gp/static/”
<Directory “C:/Python27/code/gp/static”>
Allow from all
</Directory>
# 设置root,不要使用”^/”
WSGIScriptAlias / “C:/Python27/code/gp/apache/django.wsgi”
<Directory “C:/Python27/code/gp/apache”>
Allow from all
</Directory>
django.wsgi内容:
import os
import sys
#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
os.environ['DJANGO_SETTINGS_MODULE'] = ‘gp.settings‘
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
启动Apache即可。
Apache:Apache HTTP Server (httpd) 2.2.19
Python:Python2.7
Django:Django-1.3
Mod_wsgi.so:mod_wsgi-win32-ap22py27-3.3.so
1、下载相应Python和Apache版本的mod_wsgi.so,比如:
mod_wsgi-win32-ap22py27-3.3.so – Apache 2.2 / Python 2.7
2、下载只有一个文件:mod_wsgi.so,如果文件不是该文件名,请修改文件名。将该文件拷贝到Apache的modules目录
3、Apache的httpd.conf文件中最后加入以下两行:
LoadModule wsgi_module modules/mod_wsgi.so
Include “C:/Python27/code/gp/apache/apache_django_wsgi.conf”
第一行是让apache加载mod_wsgi模块
第二行是让apache加载web应用程序的配置文件,其中apache_django_wsgi.conf这个文件可也可以在httpd.conf文件里面,这样提取出来有利于维护。
4、创建django程序,比如我上面的gp程序放置在“C:/Python27/code/”里面。
5、在gp目录下创建一个apache文件夹,里面有两个文件:apache_django_wsgi.conf和django.wsgi。
apache_django_wsgi.conf文件内容:
# 设置django admin静态资源的访问路径
Alias /static/ “C:/Python27/code/gp/static/”
<Directory “C:/Python27/code/gp/static”>
Allow from all
</Directory>
# 设置root,不要使用”^/”
WSGIScriptAlias / “C:/Python27/code/gp/apache/django.wsgi”
<Directory “C:/Python27/code/gp/apache”>
Allow from all
</Directory>
django.wsgi内容:
import os
import sys
#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
os.environ['DJANGO_SETTINGS_MODULE'] = ‘gp.settings‘
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
启动Apache即可。
作者: YuNa123 发布时间: 2011-09-20
差不多了哦
加这个
import sys
sys.stdout = sys.stderr
在linux上的话还要
import os
os.environ['PYTHON_EGG_CACHE'] = '/your/path/to/python-eggs'
加这个
import sys
sys.stdout = sys.stderr
在linux上的话还要
import os
os.environ['PYTHON_EGG_CACHE'] = '/your/path/to/python-eggs'
作者: notax 发布时间: 2011-09-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28