zoukankan      html  css  js  c++  java
  • windows server 部署Django(Apache方式)

    http://blog.csdn.net/mandmg/article/details/60963721

    静态文件的问题:

    https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/

    https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/modwsgi/#serving-files

    http://jingyan.baidu.com/article/db55b609a93b114ba30a2ffb.html

    https://www.oschina.net/question/2517356_2141213

    安装环境:windows server 2008 R2 64bit,

    使用python python-3.6.1-amd64,下载地址,Apache HTTP server2.4_X64,下载地址

    ,mod_wsgi下载地址,选择mod_wsgi‑4.5.15+ap24vc14‑cp36‑cp36m‑win_amd64.whl,

    常规安装好apache,python,pip install django之后,

    在。whl文件的目录中,pip install mod_wsgi-4.5....whl,

    运行命令mod_wsgi-express module-config,在我的环境中,出现

    LoadFile "c:/python/python36.dll"
    LoadModule wsgi_module "c:/python/lib/site-packages/mod_wsgi/server/mod_wsgi.cp3
    6-win_amd64.pyd"
    WSGIPythonHome "c:/python"

    ,这些在Apache配置文件中会用到。

    我将Django工程文件放在C:pythonweb文件夹下.

    在Apache2.4/conf/httpd.conf 文件中,在LoadModule下面添加

    LoadFile "c:/python/python36.dll"
    LoadModule wsgi_module "c:/python/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"

    最好手敲。

    然后添加

    ServerName 你的IP:80
    WSGIPythonHome "C:python"
    WSGIScriptAlias / C:pythonwebmysitemysitewsgi.py
    WSGIPythonPath C:pythonwebmysite
    <Directory C:pythonwebmysite>
    <Files wsgi.py>
    Require all granted
    </Files>
    </Directory>

    重启httpd 即可。如果出现Requested Operation Failed,可能是conf文件配置的问题,在bin文件夹中,cmd方式输入httpd -k start

    看看错误信息。

    /admin站点前端显示不正常的问题。

    相关的js css文件没有加载。解决如下:

    1.在settings.py文件中添加

    STATIC_ROOT='C:pythonwebmysitestatic'

    2.执行命令python manage.py collectstatic,此时,相关静态文件就会复制到STATIC_ROOT中

    3.在httpd.conf 文件中添加

    Alias /static C:pythonwebmysitestatic
    <Directory C:pythonwebmysitestatic>
    Require all granted
    </Directory>

    重启httpd。

  • 相关阅读:
    微前端的那些事儿
    网络是怎样连接的 作者户根勤 交流论坛
    数据结构与算法学习
    cpu读取指令时读取的长度
    小程序开发
    npm 安装 chromedriver 失败的解决办法
    Git:代码冲突常见解决方法
    Android通过Chrome Inspect调试WebView的H5 App出现空白页面的解决方法(不需要FQ)
    pm2
    多媒体技术及应用
  • 原文地址:https://www.cnblogs.com/legion/p/7018732.html
Copyright © 2011-2022 走看看