• win7 32位配置apache+wsgi+django环境


    1下载xampp,里面有apache,mysql,phpmyadmin,

    2 下载wsgi,http://download.csdn.net/download/copter/9192361

    将对应的模块解压放到D:programsxamppapachemodules

    然后到D:programsxamppapacheconfhttpd.conf中

    # 添加mod_wsgi.so 模块
    LoadModule wsgi_module modules/mod_wsgi.so

    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf

    查看上面那行是否未注释,如注释 ,则解注释,

    3 到D:programsxamppapacheconfextrahttpd-vhosts.conf中

    <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "D:/pyprojects/ai123"
    ServerName localhost
    ServerAlias localhost
    WSGIScriptAlias /ai123/ D:/pyprojects/ai123/ai123/wsgi_local.py   /wsgi跳转
    ErrorLog "logs/vai123-error.log"
    CustomLog "logs/vai123-access.log" common
    <Directory "D:/pyprojects/ai123">  #添加目录权限
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
    </VirtualHost>

    添加上面代码,

    4

    到 D:/pyprojects/ai123/ai123/wsgi_local.py中

    import os
    import sys
    from django.core.wsgi import get_wsgi_application

    path = 'D:/pyprojects/ai123'
    if path not in sys.path:
      sys.path.append(path)

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ai123.settings")
    #os.environ['PYTHON_EGG_CACHE'] = '/tmp/.python-eggs'  # mac或linux系统中可能需要
    application = get_wsgi_application()

    对应代码如上

    5 修改mysql root密码,

    set password for root@localhost=password('111111');

    将mysql root用户 密码修改为和django里面settings.py里面的密码一致

    6 重启 apache,访问localhost/ai123即可

    如果中间访问不了,可以先在ai123下新建一个hello.wsgi文件

    内容:

    def application(environ, start_response):
      start_response('200 OK', [('Content-Type', 'text/html')])
      return '<h1>Hello, web!</h1>'

    访问localhost/ai123应出现hello,同时测试时

    WSGIScriptAlias /ai123/ D:/pyprojects/ai123/ai123/wsgi_local.py   /wsgi跳转

    改为

    WSGIScriptAlias /ai123/ D:/pyprojects/ai123/hello.wsgi   /wsgi跳转

  • 相关阅读:
    XHTML基础问答-给初学者
    动态改变表格的行数列数(添加表格)
    记录的添加,修改,删除等操作,??
    数据绑定
    优秀ASP.NET程序员修炼之路
    关于Command的ExecuteNonQuery(),ExecuteScalar(),ExecuteReader方法的区别
    MyEclipse7.5注册
    实用JavaScript代码库
    解决数据库录入中文数据乱码问题
    Oracle占用8080端口问题的解决
  • 原文地址:https://www.cnblogs.com/xqnq2007/p/7450823.html
Copyright © 2020-2023  润新知