在 apache 配置 python-django

1,在wsgi.py 添加

 

import sys

root_path= os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

sys.path.insert(0,root_path)

 

2, settings.py

    ALLOWED_HOSTS = ['*'] # 添加 *

   或

ALLOWED_HOSTS = ['127.0.0.1', 'localhost']

3 配置Apache ,httpd.conf

 根据自己配置添加

1.把whl文件改成zip,解压缩,把里面的mod_wsgi.so拷贝到E:\Apache24\modules路径下,httpd.conf 中新增一段配置:
#添加mod_wsgi.so 模块  
LoadModule wsgi_module modules/mod_wsgi.so  

 

若mod_wsgi解压后找不到mod_wsgi.so文件(如有跳过此步骤)

运行cmd,进入Scripts目录执行安装操作:

pip3 install mod_wsgi-4.5.17+ap24vc10-cp34-cp34m-win_amd64.whl

在Scripts目录执行:mod_wsgi-express module-config 

 

 

 添加到 apache httpd.conf  moud;

LoadFile "c:/python/python37.dll"
LoadModule wsgi_module "c:/python/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
WSGIPythonHome "c:/python"

 

 

 

添加端口号:

Listen 9099

 

在httpd.vhosts.conf  添加配置信息

<VirtualHost *:9099> 
ServerAlias ****:9099     # 添加域名或地址:127.0.0.1
DocumentRoot C:\django\myporoject\myporoject
WSGIScriptAlias / C:/django/myporoject/myporoject/wsgi.py

<Directory "C:\django\myporoject\myporoject">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

</VirtualHost>

 

   

posted on 2018-10-19 14:57  奔跑的葛根  阅读(217)  评论(0编辑  收藏  举报

导航