Django上线部署之Apache

环境:
  1.Windows Server 2016 Datacenter 64位
  2.SQL Server 2016 Enterprise 64位
  3.Python 3.6.0 64位
  4.administrator用户,无域环境,最高权限

要求:
  按照顺序部署

1.安装数据库

2.安装数据库客户端【SSMS】

3.安装Python

4.下载apache2.4(httpd-2.4.41-win64-VC14.zip

5.解压至C盘根目录,打开cmd执行:C:\Apache24\bin\httpd.exe -k install

6.下载编译后的wsgi(mod_wsgi-4.5.24+ap24vc14-cp36-cp36m-win_amd64.whl

7.cmd执行:pip install 【路径】\mod_wsgi-4.5.24+ap24vc14-cp36-cp36m-win_amd64.whl

8.cmd执行:mod_wsgi-express module-config(执行结果追加到【httpd.conf】)

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

9.修改【httpd.conf】

  Define SRVROOT "c:/Apache24"(默认不动)
  ServerName 【IP】:80(修改IP)
  Include conf/extra/django.conf(添加这一行)

10.在C:\Apache24\conf\extra添加【django.conf】文件,内容如下:

LoadFile "d:/programs/python36/python36.dll"
LoadModule wsgi_module "d:/programs/python36/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIPythonHome "d:/programs/python36"
WSGIPythonPath "${SRVROOT}/htdocs/MySite"
WSGIScriptAlias / "${SRVROOT}/htdocs/MySite/Project/wsgi.py"

<VirtualHost *:80>
ServerName "192.168.70.111"
DocumentRoot "${SRVROOT}/htdocs/MySite"
ErrorLog "logs/Project-error.log"
CustomLog "logs/Project-access.log" common
</VirtualHost>

Alias /media/ "${SRVROOT}/htdocs/MySite/media/"
<Directory "${SRVROOT}/htdocs/MySite/media/">
Require all granted
</Directory>

Alias /static/ "${SRVROOT}/htdocs/MySite/static/"
<Directory "${SRVROOT}/htdocs/MySite/static/">
Require all granted
</Directory>

<Directory "${SRVROOT}/htdocs/MySite/Project/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>

11.启动c:\Apache24\bin\ApacheMonitor.exe

转载于:https://www.cnblogs.com/Siriusmath/p/11393784.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值