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
根据自己配置添加
#添加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:djangomyporojectmyporoject
WSGIScriptAlias / C:/django/myporoject/myporoject/wsgi.py
<Directory "C:djangomyporojectmyporoject">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>