MAC 自带的APACHE、python
一、安装mod_wscgi
下载地址:https://pypi.python.org/pypi/mod_wsgi 、http://modwsgi.readthedocs.org/en/master/
我用的版本:mod_wsgi-4.4.10.tar
# tar -zxvf mod_wsgi-4.4.10.tar
# cd mod_wsgi-4.4.10
# ./configre
# make
# sudo make install
二、下载Django
下载地址:https://www.djangoproject.com/m/releases/1.6/Django-1.6.11.tar.gz
# tar -zxvf Django-1.6.11.tar.gz
# cd Django-1.6.11
# python setup.py install
三、APACHE 配置加载wsgi
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
APACHE 虚NI域名配置
#DocumentRoot "/Users/user/Project/python/djangoapp"
ServerName test.djangoapp.com
WSGIScriptAlias / /Users/user/Project/python/djangoapp
AddType text/html .py
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error-django_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
#Options Indexes FollowSymLinks MultiViews
#AllowOverride None
#AddHandler cgi-script cgi pl
Options ExecCGI
Order deny,allow
Allow from all
四、生成项目
# django-admin.py startapp djangoapp
五、测试django 生成的WEB 是否安装成功
1.新建视图在项目目录下views.py
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world")
2. RULconf设置 将项目下的urls.py修改成如下内容
from django.conf.urls.defaults import *
from mysite.views import
urlpatterns = patterns('',
('^hello/$', hello),
)
3. 启动Django开发服务器来测试修改好的 URLconf, 运行命令行 python manage.py runserver
打开你的浏览器访问 http://127.0.0.1:8000/hello/
如果输出hello word 就正确